Repository navigation
Conversation
This branch has not been deployed
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.
AsyncAbsurd._ensure_connectedonly connects when_conn is None, and nothing ever resets_conn, so an owned connection that dies underneath the client (idle timeout, server restart, network blip) is terminal: every later call raisespsycopg.OperationalError: the connection is closeduntil the process restarts. We hit this in production with a long-lived client whose connection sits idle between scheduler ticks; one dropped connection permanently broke every subsequentspawn.This makes
_ensure_connectedtreat an owned connection whosebrokenflag is set as reconnectable. psycopg'sbrokenis true only for connections that terminated abnormally, so:close()d client stays closed (no surprise resurrection),_owned_conn = False) is never replaced, since the caller owns its lifecycle.The call that discovers the dead connection still raises (psycopg only marks the connection broken when an operation fails on it); the next call reconnects instead of failing forever.
The sync client connects eagerly in
__init__and doesn't keep the conn string, so it isn't covered here; happy to follow up on it (and the TS SDK, which looks similar) if you want the same semantics there.AI Disclaimer
This PR was developed with the assistance of either Claude or Codex. I've reviewed and verified the changes.