Repository navigation
fix(sql-pg): retire a session whose CancelRequest may be in flight - #8330
Merged
Merged
Conversation
🦋 Changeset detectedLatest commit: 96cfea2 The changes in this PR will be included in the next version bump. This PR includes changesets to release 31 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
Contributor
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|
tim-smart
enabled auto-merge (squash)
September 20, 2026 23:49
Merged
arrudaricardo
pushed a commit
to arrudaricardo/effect
that referenced
this pull request
Sep 23, 2026
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.
Summary
PgConnection.queryandPgConnection.streamsend aCancelRequestwhen interrupted work does not drain promptly. The request uses a side connection with no delivery confirmation. A pooler or proxy can delay it long enough for the cancel to hit the next statement on the same PostgreSQL session.This keeps the diagnosis and proxy coverage from #8306, but centralizes cancel tracking on the connection and shares one abort-drain path between queries and streams.
The fix
drainAbortedgives an interrupted statement 10 ms to reachReadyForQuerybefore sending a cancel, avoiding unnecessary cancels for buffered results. Once sent,cancelPendingstays set until the backend reports57014.If
ReadyForQueryarrives first, the connection fires its retirement hooks. A pool invalidates the session before another checkout can receive it, while an existing checkout keeps its lease until release. An interrupt sent while the connection is idle retires it immediately because no active statement can confirm the cancel.PgPool.useretains thePool.usefast path when no connection TTL is configured and no session is waiting to be retired. The unpinned multiplexed path never cancels and is unchanged.A caller that keeps using the same checkout remains exposed to its own late cancel. An unpooled session has no retirement hook or replacement boundary and remains exposed for the rest of its lifetime. Also,
statement_timeoutreports57014, so it can be mistaken for confirmation that the cancel arrived.Tests
PgPool.integration.test.tshas 23 cases covering confirmed and unconfirmed query and stream cancels, replacement throughpool.getandpool.use, held-session behavior, buffered stream drains, late-cancel isolation, and idle interrupts.The cancellation fixtures synchronize through advisory locks and proxy gates rather than depending on row-count timing.
Validation
PgPool.integration.test.tscases pass with testcontainersgit diff --checkpassCloses EFF-1445
Closes #8306