Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrations not executed with Node 18, stuck on connecting #816

Closed
1 of 3 tasks
tomiadebanjo opened this issue May 3, 2023 · 13 comments
Closed
1 of 3 tasks

Migrations not executed with Node 18, stuck on connecting #816

tomiadebanjo opened this issue May 3, 2023 · 13 comments

Comments

@tomiadebanjo
Copy link

tomiadebanjo commented May 3, 2023

I'm submitting a...

  • Bug report
  • Feature request
  • Question

Current behavior

After upgrading to Node 18, db-migrate does not execute the migrations but exits silently without any error message.

We are using a PostgreSQL db. db-migrate seems to try connect, but no matter if the database is running or not, the process exists without any notice.

After going back to Node v16 everything works again as expected.

Expected behavior

Migrations should run

Minimal reproduction of the problem with instructions


      const dbmigrate = DBMigrate.getInstance(true, {
        config: {
          'heroku-ssl': {
            url: databaseUrl,
            addIfNotExists: {
              native: true,
              sslmode: 'require',
              rejectUnauthorized: false,
            },
            overwrite: {
              native: true,
              sslmode: 'require',
              rejectUnauthorized: false,
            },
          }
        },
        cmdOptions: {
          table: 'schema_migrations',
          'migrations-dir': migrationsDirPath,
          verbose: true,
        },
      });
     dbmigrate.up()

What is the motivation / use case for changing the behavior?

Environment



db-migrate version: 0.11.11
db-migrate-pg: 1.2.1
Database version: PostgreSQL 14.7

Additional information:
- Node version: 18.15.0
- Platform:  Heroku

Others:

Runs locally on Node18, but fails to run in a node docker container - node:18.15.0-alpine3.16
@tomiadebanjo
Copy link
Author

Similar to these previous issues - #692 and #709

@tomiadebanjo
Copy link
Author

@wzrdtales Can you have a look?

@wzrdtales
Copy link
Member

not enough information.

include verbose run
include database version

only common information i can share:

remove native: true, it doesn't work properly with node 18 anymore, also the issues are mostly appearing together with SSL. See brianc/node-libpq#94

@wzrdtales
Copy link
Member

wzrdtales commented May 3, 2023

if you're using ssl auth, this might be your issue. i just ported from the cockroachdb driver the SSL handling over to the pg driver version v1.2.3. It accepts and uses the same params which are used with the native pg lib.

Example

{
  "dev": {
    "user": {"ENV": "user"},
    "driver": "pg",
    "database": {"ENV": "database"},
    "native": true,
    "host": { "ENV": "host" },
    "port": 26257,
    "ssl": {
      "sslrootcert": { "ENV": "ca_crt" },
      "sslcert": { "ENV": "ssl_cert" },
      "sslkey": { "ENV": "ssl_key" },
      "sslmode": { "ENV": "ssl_mode" }
    }
  }
}

@tomiadebanjo
Copy link
Author

@wzrdtales
Database version - PostgreSQL 14.7
Logs for a verbose run with the native config removed


[INFO] require: db-migrate-pg
[INFO] connecting
[INFO] connected
[SQL] show server_version_num
"message":"Migration Failed: no pg_hba.conf entry for host \"*\", user \"*******\", database \"********\", no encryption"

Logs for a verbose run with the native config


[INFO] require: db-migrate-pg
[INFO] connecting
Segmentation fault

@tomiadebanjo
Copy link
Author

tomiadebanjo commented May 10, 2023

It runs locally on Node18 but fails to run in a node docker container - node:18.15.0-alpine3.16.
Any thoughts on how to get other logs about the segmentation fault or the library errors?

@wzrdtales
Copy link
Member

these are not verbose logs. verbose logs contain more information. do not strip information away... .

anyhow the segmentation fault on node 18 is expected with native. so stop using it. I can't do anything about it, this is the fault of brianc/node-libpq#94 . So you will have to ask there for a fix.

@wzrdtales
Copy link
Member

the latest pg driver and cockroachdb driver do have a config parser for the SSL parameters to work with the non native version, that is what we are using since this broke (we use the cockroachdb driver).

@wzrdtales
Copy link
Member

and btw. it runs locally only b/c of some special constraints then in your setup. The whole issue is about openssl being upgraded to version 3.

@tomiadebanjo
Copy link
Author

Okay, thanks. I'll check my setup to try to find the special constraints. Heroku only provides a DB connection string. We don't have the SSL parameters for the non-native mode.

@wzrdtales
Copy link
Member

end of story is, find out how to run it without the native mode. If there are issues with the non native mode and you provide me with the information what exactly doesn't work, I can look what can be done.

@wzrdtales
Copy link
Member

and that you don't have ssl params is wrong.

sslmode: 'require',

in your example it is there. I suggest just install the latest db-migrate-pg driver and just try with native disabled, it may just work

@tomiadebanjo
Copy link
Author

Using the latest db-migrate-pg driver fixed the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants