Prepare handles describe failure#2418
Merged
Merged
Conversation
Allows wrapping or modifying net.Conn after network connection establishment but before PostgreSQL protocol communication begins.
A failure that occurred after a successful Parse could leave a prepared statement on the server that must be deallocated before re-preparing. Also, introduce a testing utility faultyconn.Conn that can be used to intercept and modify frontend messages. This is used to induce difficult difficult to reproduce timing and protocol errors in tests.
Owner
Author
|
@oschwald This approach is a bit more elegant than my previous PR. The new |
|
Thank you! We will try it out. |
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.
This handles a
Prepare()that fails afterParseCompletebut before receiving the complete statement description. Previously, this could leave a prepared statement on the server without pgx knowing about the statement. This could cause repeated failures as pgx continued to try to prepare the statement and failed.Solved by detecting that error specifically and deallocating the statement during the next Prepare.
The same error in batches was already handled via invalidating the newly prepared statements in the statement cache.
Also, introduces faultyconn package which allows introducing difficult to reproduce errors into the PostgreSQL connection. This allowed creating a delay between the
ParseandDescribemessages which reliably reproduced this error in tests.faultyconn required adding
AfterNetConnecthook topgconn.Config. While this is mostly useful for testing, it could also be useful for logging or production diagnostics.Fixes #2223
Supersedes #2411.