Conversation
Keep reserve waiters queued when a connection attempt starts, including reconnects after a server-side close. Clear the closed session query state so a stale fatal error cannot reject a new reserve. Add real-server regressions for queued reserves and terminated in-flight queries.
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 queued
reserve()can wait forever when the server terminates a connection. The close handler removes the waiter from the pool queue and passes it into reconnect. Connection startup discards that reserve marker, expecting the pool queue to still contain the waiter, so nothing resolves it.Keep reserve waiters in the pool queue whenever a connection attempt starts, including reconnects. The normal open handler can then hand out the connection. Also clear the closed session's query, results, and pending error: otherwise a fatal error from an interrupted query can reject a new reserve, and the pool hands the reconnected slot to that already-rejected waiter. A waiter rejected by a failed connection attempt removes itself from the queue, so the pool neither keeps reconnecting for it nor hands a later connection to it.
Adds two tests using the existing
t()harness and a real server: terminate a reserved backend while another reserve is queued, and terminate a reserved backend while a query is sleeping before reserving again. Both fail before the patch and pass afterward.Validation:
npm testpasses, 266 tests each for ESM, CommonJS, and Deno.Fixes #1195