Repository navigation
fix(pg): settle a query once when bind serialization throws - #3835
Open
princejain756 wants to merge 1 commit into
Open
princejain756 wants to merge 1 commit into
princejain756 wants to merge 1 commit into
Conversation
When a parameter fails to serialize, connection.bind() throws before any bind message reaches the wire. The catch reported the error through the callback immediately, but the query stayed active, so the server's ReadyForQuery answer to our sync settled the same query a second time as a success with zero rows. Defer the error through the existing _canceledDueToError channel so handleReadyForQuery reports it exactly once. Fixes brianc#3820
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.
Fixes #3820
Since 8.22.0 a query whose parameter fails to serialize (a throwing
toPostgres(), a BigInt in a JSON value, a circular object) settles twice: once with the error, then again as a success with zero rows.connection.bind()throws before any bind message reaches the wire, and the catch inQuery#preparereported the error through the callback right away. The query stayed active, so when the server answered the follow-upsyncwithReadyForQuery,handleReadyForQuerysettled the same query again with(null, results).The error now goes through the existing
_canceledDueToErrorchannel, sohandleReadyForQueryreports it exactly once when the server responds, and no success settlement can follow.Validation: added a "settles the query exactly once" unit test that fails on the old code (callback invoked twice) and passes now; the three existing bind-throw tests were updated to emit the
readyForQuerya real server sends in reply tosync.make test-unitpasses 288 tests and eslint is clean.