Fix shutdown double-notification across in-flight query states#115
Merged
SeanTAllen merged 1 commit intomainfrom Feb 13, 2026
Merged
Fix shutdown double-notification across in-flight query states#115SeanTAllen merged 1 commit intomainfrom
SeanTAllen merged 1 commit intomainfrom
Conversation
…ery split across TCP segments When an in-flight query state's on_error_response notifies a receiver of failure, the queue item stays in place — removal is deferred to on_ready_for_query. If close() arrives before ReadyForQuery (possible when they land in separate TCP segments), _SessionLoggedIn.on_shutdown drains the queue and sends a second failure notification to the same receiver. Add drain_in_flight() to _QueryState so each in-flight state can handle its own queue item during shutdown — skipping notification if on_error_response already fired, then unconditionally shifting the item. The subsequent drain loop only sees genuinely queued (never-started) items. Add _error tracking to _SimpleQueryInFlight and _ExtendedQueryInFlight (PrepareInFlight and CopyInInFlight already had it) so all in-flight states can distinguish "already notified" from "needs notification". Closes #114
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.
When an in-flight query state's
on_error_responsenotifies a receiver of failure, the queue item stays in place — removal is deferred toon_ready_for_query. Ifclose()arrives before ReadyForQuery (possible when ErrorResponse and ReadyForQuery land in separate TCP segments),_SessionLoggedIn.on_shutdowndrains the queue and sends a second failure notification to the same receiver.Most visible with COPY IN (the client round-trip between CopyFail and ErrorResponse+ReadyForQuery widens the timing window), but the same pattern exists in all in-flight query states.
Adds
drain_in_flight()to_QueryStateso each in-flight state handles its own queue item during shutdown — skipping notification ifon_error_responsealready fired, then unconditionally shifting the item out of the queue. The subsequent drain loop only sees genuinely queued (never-started) items.Also adds
_errortracking to_SimpleQueryInFlightand_ExtendedQueryInFlight(_PrepareInFlightand_CopyInInFlightalready had it).Closes #114