[READY FOR REVIEW] [DO NOT MERGE] fix prepared statement cache invalidation #860
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 patch fixes #841. To fix it we notice
when a statement failed because its cached plan is now
invalid and flush it from our cache. We don't try to get
fancy with retries or anything like that, just return the
error and allow the application to handle it.
The flushing of statements is deferred to the end of transactions
because all statements executed after an error in a transaction
will just result in errors. If we are not in a transaction, we
flush eagerly.
I had to make some changes to to the jackc/pgconn package as well
as this package, so I've retargeted this this repo on
ethanpailes/pgconn for the time being. This PR is not really in a
mergable state until those PRs merge and I rip out 2f31e98, but I
would say it is ready for review (just review the most recent commit).
One question I have is whether anything else needs to be done around
batch SQL, so guidance there would be appreciated.
Fixes #841