Repository navigation
Handle misuse rejects with TRANSACTION_ENDED or CONNECTION_RELEASED, not CONNECTION_ENDED - #185
Merged
Merged
Conversation
okomarov
force-pushed
the
error-codes-138
branch
from
October 23, 2026 11:32
ec3ffdc to
afadd79
Compare
…s CONNECTION_CLOSED until the owner is done Reserved handles after release() expect CONNECTION_RELEASED, transaction handles after their transaction ended expect TRANSACTION_ENDED, and CONNECTION_ENDED stays for sql.end(). A new scenario pins that a transaction handle leaked from a callback that outlived its dropped connection gets TRANSACTION_ENDED, not CONNECTION_CLOSED.
okomarov
force-pushed
the
error-codes-138
branch
5 times, most recently
from
October 23, 2026 13:12
dbd7f6e to
c20f997
Compare
…SED, not CONNECTION_ENDED A lease's state says what the handle is doing: Active (in use), Closed (in use, but its connection closed), Settling (a transaction finishing its COMMIT, ROLLBACK or PREPARE), Ended (a transaction that is over) or Released (a reservation that has been released). A transaction ends when its callback has finished, even if begin() already rejected because the connection closed. stop() records that and returns the connection only if the lease still holds it; the caller then releases or terminates it. No longer CONNECTION_ENDED: - a reserved handle used after release() or dispose: CONNECTION_RELEASED - a statement queued on a reserved handle when release() ran: CONNECTION_RELEASED - a transaction handle used after commit, rollback or prepare: TRANSACTION_ENDED - a transaction handle used while COMMIT, ROLLBACK or PREPARE TRANSACTION is in flight: TRANSACTION_ENDED - a savepoint on a transaction handle that started late or finished after the transaction ended: TRANSACTION_ENDED No longer CONNECTION_CLOSED: - a reserved handle used after release() when its connection had closed first: CONNECTION_RELEASED - a transaction handle used after its begin() callback finished when its connection had closed first: TRANSACTION_ENDED CONNECTION_ENDED now means only sql.end(): new queries, reserve() and begin() after it, and reserve() or begin() waiting when it was called. Closes #138
…, and connection-ended-check is info Handle misuse no longer raises CONNECTION_ENDED, so a retry set that lists it does not need the misuse codes. The README review examples drop the CONNECTION_ENDED mention.
okomarov
force-pushed
the
error-codes-138
branch
from
October 23, 2026 13:17
c20f997 to
5264e6a
Compare
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.
A reserved handle used after
release()now rejects withCONNECTION_RELEASED. A transaction handle used after its transaction ended, or while its COMMIT, ROLLBACK or PREPARE runs, now rejects withTRANSACTION_ENDED. Both come fromErrors.generic, so the message names the mistake instead of readingwrite CONNECTION_ENDED host:port.CONNECTION_ENDEDagain means only thatsql.end()was called, andCONNECTION_CLOSEDis unchanged.Five of the 20 most-starred apps using
postgresretryCONNECTION_ENDEDas transient, so use-after-release bugs were being retried and logged as connection blips.api.md,lifecycle.md,upgrading.md) say which cases moved.CONNECTION_ENDEDcheck drops to info, because code that checks forCONNECTION_ENDEDbehaves the same as on 3.4.9.Closes #138