New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unnecessary use of v3 Parse/Bind/Execute and named portal sending BEGIN for COPY #1638
Comments
Workarounds:
|
It looks like there's an opportunity to detect if the connection has been put in read-only state and send the read-only begin instead. I haven't made that change at the same time. |
Will send a PR, but here's the patch I expect will do the trick
|
Is it baked with the measurements? |
When autocommit is off and the first query in a transaction is a COPY, we were sending a BEGIN using the extended query protocol. It was being permitted to use named portals as well, ignoring prepareThreshold. Fix by forcing simple query mode and marking the BEGIN as oneshot. Fixes pgjdbc#1638
Created as #1639 Backed by measurements? No, but we don't use extended query protocol for Look at |
Note that this is very much a bug fix - we use extended query protocol even if the query mode is set to It just so happens that it's a pretty harmless bug unless you're using a weird pooler configuration. |
When autocommit is off and the first query in a transaction is a COPY, we were sending a BEGIN using the extended query protocol. It was being permitted to use named portals as well, ignoring prepareThreshold. Fix by forcing simple query mode and marking the BEGIN as oneshot. Fixes #1638
Thanks @davecramer :) much appreciated. Tried to supply a decent report to make it easy. |
Bug.
PgJDBC uses a v3 protocol Parse/Bind/Execute and may use a named portal ("prepared statement" at the protocol level) when autocommit is off, there is no in-progress transaction and a
COPY
operation is started via theCopyManager
.This is inefficient but mostly harmless. However, it upsets setups that use PgBouncer in transaction pooling mode with round-robin and/or a server lifetime limit, since the named portal for the
BEGIN
may vanish out from under PgJDBC. If this happens, the trace log should contain something like:This will be the case even if
prepareThreshold=0
.There's no good reason to use the extended query protocol for
BEGIN
so I'll submit a patch to force simple query mode.The text was updated successfully, but these errors were encountered: