Skip to content

Fix shutdown double-notification across in-flight query states#115

Merged
SeanTAllen merged 1 commit intomainfrom
fix-shutdown-double-notification
Feb 13, 2026
Merged

Fix shutdown double-notification across in-flight query states#115
SeanTAllen merged 1 commit intomainfrom
fix-shutdown-double-notification

Conversation

@SeanTAllen
Copy link
Member

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 ErrorResponse and ReadyForQuery land in separate TCP segments), _SessionLoggedIn.on_shutdown drains 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 _QueryState so each in-flight state handles its own queue item during shutdown — skipping notification if on_error_response already fired, then unconditionally shifting the item out of the queue. The subsequent drain loop only sees genuinely queued (never-started) items.

Also adds _error tracking to _SimpleQueryInFlight and _ExtendedQueryInFlight (_PrepareInFlight and _CopyInInFlight already had it).

Closes #114

…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
@ponylang-main ponylang-main added the discuss during sync Should be discussed during an upcoming sync label Feb 13, 2026
@SeanTAllen SeanTAllen merged commit b446bb6 into main Feb 13, 2026
10 checks passed
@SeanTAllen SeanTAllen deleted the fix-shutdown-double-notification branch February 13, 2026 03:41
@ponylang-main ponylang-main removed the discuss during sync Should be discussed during an upcoming sync label Feb 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CopyIn/Abort test intermittently flaky due to client-side timing

2 participants