You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FIXED in 4.1.0] Cancelling a pipelined query that hasn't started can give the next query its result #48
Claim: a query that was already written to the connection, pipelined behind another, can be cancelled before it starts. ReadyForQuery then skips it, but PostgreSQL still sends that statement's answer, which is read as the next query's. The report includes a repro: a max: 1 reserved connection with three unsafe queries, where the middle one is cancelled while the first sleeps.
Status: fixed in 4.1.0 by ab0b431, which replaced the skipping loop with pipelined(), the same change porsager#1256 proposes. phase:cancel-pipelined (tests-startup/startup.js) reproduces it on a fake server and failed before that commit. Not claimed yet, because no test runs the report against real PostgreSQL.
A CancelRequest is still sent when queries are pipelined behind the cancelled one; that is the race the README documents.
By reading, a cancelled pipelined prepared statement that hits a cached-plan error never settles: retry() hands it to submit(), which returns early for a cancelled query. Test it; open its own issue if it reproduces.
From the #124 review, inferred and not reproduced: a retried query goes to the end of sent with active still true from its first turn. If it is cancelled while waiting there, cancel() takes the current-query branch and sends the CancelRequest at once, so it can hit whichever query the backend is running. Same misdirected-cancel race as the second point above.
Fixed in 4.1.0 (ab0b431). The reporter's reserve() repro is now a real-PostgreSQL test (c2e04d7) that fails on 3.4.9 as reported and passes here; README row in c5fa99b. The cached-plan follow-up became #123 (fixed, 2a2866e). The misdirected CancelRequest race noted above remains as documented in the README.
changed the title [-]Cancelling a pipelined query that hasn't started can give the next query its result[/-][+][FIXED in 4.1.0] Cancelling a pipelined query that hasn't started can give the next query its result[/+]on Oct 17, 2026
Activity
okomarov commentedon Oct 16, 2026
From the #124 review, inferred and not reproduced: a retried query goes to the end of
sentwithactivestill true from its first turn. If it is cancelled while waiting there,cancel()takes the current-query branch and sends the CancelRequest at once, so it can hit whichever query the backend is running. Same misdirected-cancel race as the second point above.okomarov commentedon Oct 17, 2026
Fixed in 4.1.0 (ab0b431). The reporter's reserve() repro is now a real-PostgreSQL test (c2e04d7) that fails on 3.4.9 as reported and passes here; README row in c5fa99b. The cached-plan follow-up became #123 (fixed, 2a2866e). The misdirected CancelRequest race noted above remains as documented in the README.
okomarov commentedon Oct 17, 2026
Shipped in 4.5.0.
[-]Cancelling a pipelined query that hasn't started can give the next query its result[/-][+][FIXED in 4.1.0] Cancelling a pipelined query that hasn't started can give the next query its result[/+]