Repository navigation
Conversation
Reproductions of upstream reports need a real server and, on the source the fork started from, several of them crash the process from a setImmediate. One child process per scenario keeps one crash from hiding the others, and lets the same run be pointed at the upstream source to show each one fails. node tests-startup/run.js --reports runs every scenario through case.js like --leases does, with a longer deadline. It runs after tests/index.js because the row-level security scenario needs the roles tests/bootstrap.js creates.
… is lost Upstream 1208 commenters on Node 24 and 26 report an uncaught TypeError from nextWrite when a reserved connection is terminated and queried twice, when a backend is terminated during a statement inside sql.begin() so that begin()'s ROLLBACK crashes, and when a TCP proxy cuts the connection. Upstream 1154 shows the same stack, from a statement queued with setImmediate after the socket was set to null, with no reproduction. Each scenario waits for the client to see the close, drives the failure through a real PostgreSQL backend, and asserts the statements reject with CONNECTION_CLOSED, nothing is uncaught and the pool still answers. The mid-statement case runs with and without prepared statements. Together they produce the 1154 stack, so it has no separate scenario.
The report queues a third query behind two running ones and calls
end({ timeout }). The query must run before end() resolves and no backend
may be left on the server. max_pipeline is 0 so the third query waits in
the pool queue instead of being pipelined onto a running connection, and an
observer polls pg_stat_activity for the application name.
The test lives in tests/index.js because that file also runs on Deno,
where the runner forces an exit, so a left-over backend is the signal
there rather than a hanging process.
… connection Upstream 815 reports prefer-standby and primary multi-host setups failing with CONNECT_TIMEOUT when one host accepts the TCP connection and never answers; upstream 988 reports the same on a busy pool. A local server that accepts and stays silent stands in for the stuck host, next to the real primary on 5432 (and the plain secondary on 5433 for the pool case). The never-completing TCP connect to an unroutable address is not reproduced because CI has no address that stays unroutable. The read-write reports in the same thread are tracked separately.
Upstream 823 reports UNSAFE_TRANSACTION and notice 25001 from frequent sql.begin() calls that delete rows by a_id and insert zero to a few thousand rows, next to other queries on a busy pool. One scenario repeats that on a max 3 pool kept busy by sleeping queries, with five concurrent transactions of different sizes. The second puts BEGIN at the pipeline limit with defaults, the deterministic variant from the thread. Both check every statement resolves, each a_id has its rows, no 25001 notice is raised and no backend is left idle in a transaction. Upstream 1189 reports sql.begin() failing with "Cannot set properties of undefined (setting 'onclose')" and leaving the backend idle in a transaction when the socket's write never reports backpressure and a long query is running; the scenario uses the reporter's wrapper.
… the server Upstream 1223 reports a FATAL 57P01 on the connection that runs the type discovery query, which leaves an unhandled rejection and fails the first query. The scenario puts a TCP relay between the client and PostgreSQL that answers the first chunk containing the type query with a FATAL 57P01 and closes the connection, then asserts the next query still returns, nothing is uncaught or unhandled, and end() resolves.
Upstream 1164 reports unnest(${ array }::text[]) failing with "malformed
array literal" and returning strings when types are not fetched. The test
runs the reporter's query, then sends plain JavaScript arrays into text[]
and int4[] columns of a temporary table and reads them back as arrays, with
fetch_types off and prepare both on and off (the latter is what a pooler
such as Hyperdrive requires).
…e session Upstream 1133 sets idle_in_transaction_session_timeout inside sql.begin(), waits past it and returns, and the implicit COMMIT throws from nextWrite. Upstream 1248 describes a statement run after the connection closed inside the callback. The scenarios end the session either by the timeout or by pg_terminate_backend, wait for the client's onclose instead of sleeping, then either return from the callback or run another statement. begin() and the statement must reject with CONNECTION_CLOSED, nothing may be uncaught and the pool must answer the next query.
…uery Upstream 1199 reports a reservation whose backend is terminated while a query is running: the query never settles, release() does not recover the pool and a TypeError is thrown from a timer. The scenario runs pg_sleep(30) on a reserved connection, waits until the backend is active, terminates it, and asserts the in-flight query rejects with CONNECTION_CLOSED, release() hands the slot back, the next query returns, end() resolves and nothing is uncaught.
The begin-queued case closes the socket cleanly. The real report path for statements queued on a transaction handle is a reset, so run the same case with the fake server resetting the connection and expect the same CONNECTION_CLOSED for every queued statement.
…nection to another Upstream 1204 is a production report: with max 5, a long transaction pipelining thousands of INSERTs beside a purge sql.begin() produced notice 25001 on the inserter's backend, and the purge's COMMIT committed the inserter's partial rows. The trigger was not established by the reporter. The scenario injects the mechanism against PostgreSQL: a socket wrapper refuses a write of 1024 bytes or more and emits drain after the next data, as libuv does under backpressure. While the writer's transaction is open and its connection has drained, a second sql.begin() deletes rows. The writer must still roll back its own rows, the purge must run on another connection, and no 25001 notice may appear.
…rough row-level security Upstream 1216 reports a transaction handle whose connection was closed running its next statement inside another user's transaction on the reconnected session, and so reading rows the policy hides from its own user. The scenario enables row-level security on a table owned by the superuser, opens a transaction as the non-owner scram role with app.user_id set to one user, terminates its backend, and opens a second transaction as another user on the same max 1 pool. The first handle's select must reject with CONNECTION_CLOSED instead of returning the second user's row. It runs after tests/index.js, which creates the role.
…kend Upstream 1226 reports the query sent right after a backend was terminated mid-statement rejecting with 57P01, the error of the connection that was lost, instead of running on the new one. The scenario runs pg_sleep(30), terminates the backend once it is active, and asserts the in-flight query rejects with CONNECTION_CLOSED and the next query returns its value, with prepared statements on and off.
…is cut off Upstream 1242 reports sql.end() never resolving after the connection is lost while a transaction runs a statement. The reporter's statement had a parameter, which takes the extended-protocol path rather than the simple query path the existing lease cases hold. The fake server holds a parameterised statement inside sql.begin() on a max 5 pool, then closes or resets the connection. begin() must reject with CONNECTION_CLOSED and end() without a timeout must resolve.
…se a pool slot Upstream 1246 reports a connection reset mid-transaction leaving the pool a connection short and end() stuck. The scenario runs pg_sleep(30) inside sql.begin() on a max 10 pool behind a TCP relay, resets the client's socket once the backend is active, then runs two rounds of ten concurrent queries that each hold their connection. Each round must see ten distinct backends and end() must resolve. It uses a real server because the held queries on the fake peer never let end() resolve.
Both reports crash or leak an unhandled rejection when the catalog query that fetches array types is cancelled by the server. The existing cases inject a synthetic 57014. This one makes PostgreSQL raise it: a 1 ms statement_timeout from the startup parameters applies to the type query, and a debug hook confirms the query was sent. The first user query must reject with 57014 and nothing may be uncaught or unhandled. The fork cannot tell whether the cancel hit the type query, so the run against the upstream source is the evidence.
Temporary, dropped before merge. A non-required job puts the upstream src/ of 411429e in place, bootstraps the roles and runs the report scenarios, the new lease cases, the queued-end phase and the arrays test in tests/index.js. Every one of them must fail there; the job reports each failure's output and fails if any reproduction passes.
When a scenario fails against a client that cannot close (the upstream
source after a lost connection), end({ timeout: 0 }) in the finally block
never returns and the child is killed at its deadline before the assertion
that explains the failure is printed. Bound each shutdown so the failure
text reaches the output, and end sessions left idle in a transaction before
dropping the shared table so the drop cannot wait on them.
On a pool that has not opened a connection yet, reserve() never resolves on the upstream source when types are not fetched, so the scenarios that reserve stopped there and never reached the failure they report. Open a connection first, and warm the pipeline-limit pool with queries instead of reservations.
The row-level security, late-drain, crash and reset rows now name the behaviour the reproductions check, each of which also fails on the upstream source. The Bun-only report is dropped from the crash row with a note that the same crash on Node is covered, so the count follows. The array row says plain arrays are sent as well as decoded. The stale remark that the lifecycle reports need separate work is removed from the startup README. The pipeline row is left as it was: two of its reproductions did not fail on the upstream source.
Review of the reproductions against the upstream source found several that failed for a different reason than the report gives, or not at all. Upstream 1186: the existing queued cases use max_pipeline 0, which on the upstream source hits a different defect before any close. Add cases with the reporter's max 1 and max_pipeline 1, plain close and reset, where a queued statement must settle. Upstream 1189: start from an open connection as the reporter's script does. Upstream 823: warm the pool, then dispatch the sleeps, the selects and the transactions in that order so a BEGIN lands on the pipeline boundary. Upstream 1242: bound the shared shutdown in the lease harness so the failed step is printed. Upstream 861: add the cold max 2 pool with default pipelining from the report. Upstream 1192 and 1205: assert the user statement never reached PostgreSQL, so the cancel hit the type query. Upstream 1204: check the stored rows together with the notice. Upstream 751 is why a cold reserve hung on the upstream source: the scenarios used fetch_types false; the reserving ones now keep the default and no longer warm the pool first. Setup waits are bounded, the cleanup of sessions left in a transaction is limited to the scenario's application name, and the close of a terminated reservation is asserted.
… reproduces the report" tests-startup/README.md describes node tests-startup/run.js --reports. The README sentence that every fix has a test that reproduces the report now names the two exceptions: one rests on a production measurement and one reproduces the reported stack without a known trigger.
The temporary upstream job now gives each scenario the failure it must show on 3.4.9 and fails the check when a scenario fails with a different message, and it runs the cold pool test for the queued end().
A lease case that waits out two bounded settles needs more than five seconds to reach its assertion, so against a client that never settles the child was killed before it printed which step failed.
okomarov
force-pushed
the
test/reproduce-upstream-reports
branch
from
October 15, 2026 21:11
104faba to
762f6a4
Compare
Upstream 1186: replace the max_pipeline 1 fake-server cases, which on the upstream source fail at end() rather than at a pending statement, with the reporter's two scripts against PostgreSQL: a socket error emitted and the socket destroyed, and a pg_terminate_backend. With max 1 and max_pipeline 1, the active, sent and queued statements and the transaction must all reject. Upstream 1189: use the reporter's script, including a write that always reports the bytes as accepted and the tolerance for the secondary rejection that stock 3.4.9 emits, and assert the reporter's observables: begin() outcome, the backend's state in pg_stat_activity and whether the next query runs on the same backend. Remove the type-query-cancelled scenario: a 1 ms statement_timeout cannot be made to hit the type query deterministically.
…ream The concurrent, pipeline-limit and write-acceptance reproductions all fail on the upstream source with the reported symptoms, so the row names the cases they cover.
okomarov
added a commit
that referenced
this pull request
Oct 15, 2026
The fixed-issues table listed reports whose own scenarios had never been run here. Each now has a test that does what the reporter did, fails on the upstream 3.4.9 source with the reported symptom, and passes on the fork (fork #61; the 3.4.9 runs and their output are in PR #62). Most scenarios live in tests-startup/reports.js and run against the real CI PostgreSQL, one child process each (node tests-startup/run.js --reports), because on 3.4.9 several crash the process and a crash must not hide the others. They run after tests/index.js, which creates the roles the row-level security scenario needs. Upstream 861 and 1164 are in tests/index.js (861 also runs on Deno); 1242 and a reset case for 1186 are fake-server lease cases. What each fails with on 3.4.9: - upstream 1208, 1154, 1199, 1133, 1248: uncaught "Cannot read properties of null (reading 'write')" after a reserved or transaction connection is terminated, cut by a proxy, or ended by idle_in_transaction_session_timeout - upstream 1216: a closed transaction handle reads another user's row through row-level security - upstream 1204: notice 25001 and two rows committed by another transaction's COMMIT after a late drain - upstream 823, 1189: UNSAFE_TRANSACTION at the pipeline limit and on a busy pool; begin() leaves the backend idle in a transaction - upstream 1186: a statement queued on a transaction never settles after the connection closes - upstream 1226: the next query rejects with 57P01 - upstream 1223: a FATAL on the type query surfaces as an unhandled rejection - upstream 815, 988: CONNECT_TIMEOUT from a host that accepts and stays silent - upstream 1246: a reset transaction leaves nine backends for ten queries - upstream 1242: end() never resolves after a parameterised statement is cut off - upstream 861: end() resolves before the queued query - upstream 1164: malformed array literal for plain arrays without fetched types
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #61.
Adds a reproduction for each upstream report whose own scenario was never run here.
node tests-startup/run.js --reportsruns each real-PostgreSQL scenario in its own child process (aftertests/index.js, which creates the roles). Three scenarios live intests/index.js(it also runs on Deno) and the rest of the fake-server cases intests-startup/lease.js.The
ci:commits are temporary and will be dropped before merge. They put the upstreamsrc/of 411429e in place and run the same scenarios; each scenario has an expected 3.4.9 symptom, and the check fails if one passes or fails with a different message. Both upstream jobs (Node 24 and 26) are green, meaning every scenario failed there with its expected symptom.Results
Fork: every job is green (Node 22, 24 and 26 on PostgreSQL 15 to 18, Deno, workerd, lint).
3.4.9 failure text is the same on Node 24 and 26. "Uncaught" means the scenario's
uncaughtExceptioncapture was not empty.reserved-after-terminate,reserved-inflight-terminateCannot read properties of null (reading 'write')begin-terminated-midstatement(prepared, unprepared),begin-network-cutbegin-after-session-ended(4 variants)terminated-inflight-then-query(prepared, unprepared)57P01instead of returning 1stale-transaction-reads-through-rlsread replacement/secondinstead of rejectingCONNECTION_CLOSEDlate-drain-commits-other-transactionstored: 2(the purge's COMMIT committed the writer's rows) and notice25001, expected 0 and nonetype-query-fatalterminating connection due to administrator commandconnect-timeout-prefer-standby,connect-timeout-primaryCONNECT_TIMEOUTinstead of a backend pidconnect-timeout-busy-poolCONNECT_TIMEOUTreset-mid-beginbegin-at-pipeline-limitbegin()rejectsUNSAFE_TRANSACTIONconcurrent-begins-busy-poolbegin()calls rejectUNSAFE_TRANSACTIONin the first iterationqueued-statement-never-settles(socket error, andpg_terminate_backend), the reporter's scriptsselect 2staysstill_pendingbegin-write-always-true, the reporter's script with its unhandled-rejection tolerancebegin()rejects, backendidle in transaction, next query on the same backend, secondaryCannot read properties of undefined (reading 'queue')rejection (the report quotessetting 'onclose')begin-inflight-end,begin-inflight-end-resetbegin()rejectsCONNECTION_CLOSED, thenend()never resolves ('hang' !== 'resolved')tests/index.jsarrays without fetching typesPostgresError: malformed array literal: "foo,bar"(22P02)tests/index.jsend with a timeout, coldmax: 2poolend()resolves before the queued query:["end","query"]instead of["query","end"]tests/index.jsend with a timeout, warm pool,max_pipeline: 0Changes after review
type-query-cancelled(1192, 1205) is removed: a 1 msstatement_timeoutcannot be made to hit the type query deterministically, and it failed on the fork in 3 of 24 runs. Those rows keep resting on the existing fake-server tests.max_pipeline: 1fake-server cases for 1186 are removed: on 3.4.9 they fail atend(), not at a pending statement. The reporter's two scripts are ported instead (below).begin-queuedcases (max_pipeline: 0) fail on 3.4.9 withTypeError ... reading 'queue'atsrc/index.js:293, which is a different report.Not reproduced separately
Connection; pooled queries cannot reach a null socket on 3.4.9).