-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
pgwire: de-strictify extended protocol handling #51194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but definitely someone else should sanity check the change as well.
nit (in release note): s/while extended/while in extended/
.
Reviewed 2 of 2 files at r1.
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei, @mjibson, and @rafiss)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Maybe find a place in conn.go to put a TODO about the postgres error behavior
Reviewable status: complete! 0 of 0 LGTMs obtained (waiting on @andreimatei and @rafiss)
Previously, the protocol handler didn't permit simple queries during the extended protocol mode. I think this was done because the spec vaguely says that extended protocol commands must be ended with a SYNC command: https://www.postgresql.org/docs/9.3/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY However, an examination of the PostgreSQL source code shows that the extended protocol mode bit is only used for error recovery. If an error is encountered during extended protocol mode in Postgres, all commands are skipped until the next Sync. CockroachDB never implemented that behavior - instead, it used the extended protocol mode bit only to reject simple queries if they came before the Sync. This commit removes the extended protocol mode bit, as the use case we used it for was incorrect. It's unclear to me whether we need to re-add the bit for dealing with error cases, but we haven't needed it yet. Adding that might be follow-on work, and won't come in this PR. Release note (bug fix): prevent spurious "SimpleQuery not allowed while in extended protocol mode" errors.
275ec2e
to
a659313
Compare
TFTRs! Thoughts on a backport? I'm in favor, and I'll open one, but curious if there's dissent. bors r+ |
+1 for backport |
I support backporting |
Build succeeded |
Fixes #33693.
Fixes #41511.
Previously, the protocol handler didn't permit simple queries during the
extended protocol mode. I think this was done because the spec vaguely
says that extended protocol commands must be ended with a SYNC command:
https://www.postgresql.org/docs/9.3/protocol-flow.html#PROTOCOL-FLOW-EXT-QUERY
However, an examination of the PostgreSQL source code shows that the
extended protocol mode bit is only used for error recovery. If an error
is encountered during extended protocol mode in Postgres, all commands
are skipped until the next Sync.
CockroachDB never implemented that behavior - instead, it used the
extended protocol mode bit only to reject simple queries if they came
before the Sync.
This commit removes the extended protocol mode bit, as the use case we
used it for was incorrect. It's unclear to me whether we need to re-add
the bit for dealing with error cases, but we haven't needed it yet.
Adding that might be follow-on work, and won't come in this PR.
Release note (bug fix): prevent spurious "SimpleQuery not allowed while
in extended protocol mode" errors.