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

native driver ignores statement_timeout #2103

Open
gajus opened this issue Feb 12, 2020 · 6 comments · May be fixed by #2323
Open

native driver ignores statement_timeout #2103

gajus opened this issue Feb 12, 2020 · 6 comments · May be fixed by #2323
Labels

Comments

@gajus
Copy link
Contributor

gajus commented Feb 12, 2020

const pool = new pg.Pool({
  statement_timeout: 1000,
});

Passing statement_timeout to node-postgres when using pg-native has no effect on the statement_timeout configuration.

@brianc
Copy link
Owner

brianc commented Feb 12, 2020

This might be a pretty easy fix if you're interested in doing a PR. Otherwise I'll get to it soon-ish but I've got a bunch of other stuff in the pipeline too. 🙏

@brianc brianc added the bug label Feb 12, 2020
@gajus
Copy link
Contributor Author

gajus commented Feb 13, 2020

Switching to the JavaScript driver now throws:

      error: unsupported startup parameter: statement_timeout
          at Connection.parseE (/Users/gajus/Documents/dev/rayroute/rayman/node_modules/pg/lib/connection.js:614:13)
          at Connection.parseMessage (/Users/gajus/Documents/dev/rayroute/rayman/node_modules/pg/lib/connection.js:413:19)
          at TLSSocket.<anonymous> (/Users/gajus/Documents/dev/rayroute/rayman/node_modules/pg/lib/connection.js:129:22)
          at TLSSocket.emit (events.js:321:20)
          at TLSSocket.EventEmitter.emit (domain.js:485:12)
          at addChunk (_stream_readable.js:297:12)
          at readableAddChunk (_stream_readable.js:273:9)
          at TLSSocket.Readable.push (_stream_readable.js:214:10)
          at TLSWrap.onStreamRead (internal/stream_base_commons.js:186:23)

@boromisp
Copy link
Contributor

@gajus Could the unsupported startup parameter error be related to this: https://www.pgbouncer.org/config.html#ignore_startup_parameters?

@shayonj
Copy link

shayonj commented Aug 30, 2020

At @loomhq we are looking to see if we can using this with our sequelize setup. I noticed statement_timeout doesn't get applied when using the native driver as well. Proposed a PR to fix in #2323. Also, added support for idle_in_transaction_session_timeout.

@shayonj
Copy link

shayonj commented Sep 3, 2020

Re:

  error: unsupported startup parameter: statement_timeout

This is expected from pgbouncer, because statement_timeout is not part of ignore_startup_parameters (pgbouncer's config). However, when the fix ships it will complain on options (since we do options=-c statement_timeout=...).

The issue here is pgbouncer ignores startup parameter once added to ignore_startup_parameters (it only does so that pgbouncer doesn't hard fail), so passing statement_timeout via options to pgbouncer won't work I believe.

The fix should still work when working against DB server.

@xxRockOnxx
Copy link

@shayonj Thanks. I appreciate the explanation.

I use slonik which uses node-postgres under the hood and have to connect to PgBouncer. I keep getting "unsupported startup parameter" error and I have no clue PgBouncer is incompatible with these timeout options. Disabling them fixed it.

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