Repository navigation
Conversation
With `fetch_types: false`, a queued `reserve()` on a cold pool never settled: the ReadyForQuery handler returned early instead of falling through to `onopen()`, so nothing resolved the reserve. Fall through to match the `fetch_types: true` path, and add a cold-pool regression test.
|
Looks good, quick fix, test and comment guard against a random change of flow with the reintroduction of a |
|
Verified against a real Postgres instance:
The regression test I added ( |
The old test's SET client_min_messages query warmed the pool the same way the fix's own warm-up does, so removing the fix left the test green. Move client_min_messages into the connection options and send no query before runMigrations, so the hang reproduces again (~5s, then red). Force-close the client in finally instead of a graceful end + query, which used to hand the stuck reserve() a connection and recreate the table it was supposed to drop. porsager/postgres#1220 is an open, unmerged third-party PR against the bug filed as #1219 — not a landed upstream fix. Corrected in the doc comment, the test and README, and named the one race the workaround does not close.
* fix(server): unhang runMigrations on fetch_types: false sql.reserve() never resolved when it had to open a fresh connection on a client built with fetch_types: false — [email protected]'s ReadyForQuery only hands a new connection back to a pending reserve() through the branch that also fetches array-type OIDs, which fetch_types: false skips (upstream: porsager/postgres#1220). A plain query on the pool before reserve() leaves a connection idle, so reserve() takes the pool's synchronous already-idle path and never hits the buggy one. * fix(server): repair fetch_types test and PR reference The old test's SET client_min_messages query warmed the pool the same way the fix's own warm-up does, so removing the fix left the test green. Move client_min_messages into the connection options and send no query before runMigrations, so the hang reproduces again (~5s, then red). Force-close the client in finally instead of a graceful end + query, which used to hand the stuck reserve() a connection and recreate the table it was supposed to drop. porsager/postgres#1220 is an open, unmerged third-party PR against the bug filed as #1219 — not a landed upstream fix. Corrected in the doc comment, the test and README, and named the one race the workaround does not close. * docs(server): correct the reserve race wording The stuck connection is freed by max_lifetime, and a query after reserve() never runs; both from the round-2 reviewer of #167.
|
Hi @porsager — gentle ping on this one whenever you get a chance. It's a minimal fix (+19/−3, two files) with a regression test for #1219, and it's been verified against a real Postgres instance (unpatched master hangs, this branch settles immediately). The fork-PR CI workflow is still waiting on an "Approve and run", so the tests haven't run here yet. Happy to adjust anything or help get CI green — just let me know. |
…ehave ADR-0023 said the adapter turns off fetch_types. It does not: postgres.js 3.4.9 hangs reserve() with it off (porsager/postgres#1220), and postgres.js is a peer dependency, so a local patch can't reach users. Correct the text and add the raw-sql array consequences.
|
Thanks! This is part of v4 (06cf284), so I am closing it here. The changelog has the details: https://github.com/porsager/postgres/blob/master/CHANGELOG.md |
Fixes #1219.
reserve()on a cold pool never settles whenfetch_types: false: theReadyForQueryhandler returns early instead of falling through toonopen(), so nothing resolves the reserve. Withfetch_types: truethe array-type fetch round trip falls through and resolves it, which is why it only reproduces with the option disabled.This makes the non-fetching path fall through to
onopen()wheninitialis a reserve, and adds a cold-pool regression test.