-
Notifications
You must be signed in to change notification settings - Fork 520
Fix COPY FROM STDIN handling #1025
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
Fix COPY FROM STDIN handling #1025
Conversation
8b0532e to
e63a15c
Compare
e63a15c to
2e180f8
Compare
2e180f8 to
9aeeac4
Compare
src/server.c
Outdated
| if (!clear_outstanding_requests_until(server, "cf")) | ||
| return false; | ||
| } else { | ||
| server->query_failed = true; |
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.
This should happen always probably, otherwise we won't pop a later received CopyDone message in case of failure.
eulerto
left a comment
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. Don't forget to include test_copy.py into EXTRA_DIST target (I submitted another PR #1026 that included some recent tests into it.)
In pgbouncer#854 full tracking of expected responses was implemented. This turned out this have bugs when sending `COPY FROM STDIN` queries using the extended protocol. The protocol explicitely allows sending `Sync` messages after sending an `Execute` message for a `COPY FROM STDIN` command. Such Sync messages are ignored by the server until a CopyDone or CopyFail message is received. The new command queue tracking did not take this into account, and was incorrectly expecting more ReadyForQuery messages from the server. This PR fixes that issue. It also removes the rfq_count tracking, since it's now only keeping track of a strict subset of what the outstanding request queue was tracking. Fixes pgbouncer#1023 Fixes pgbouncer#1024 TODO: - [ ] Add tests for COPY TO STDOUT
e3048a3 to
0c7ca30
Compare
0c7ca30 to
3c25bae
Compare
|
There are some tests that still refers to table "t". |
ugh, fixed |
eulerto
left a comment
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
I realized I was a bit too trigger-happy when removing all references to expected_rfq_count in pgbouncer#1025. One occurrence should have been replaced with adding an outstanding request.
I realized I was a bit too trigger-happy when removing all references to expected_rfq_count in pgbouncer#1025. One occurrence should have been replaced with adding an outstanding request.
I realized I was a bit too trigger-happy when removing all references to `expected_rfq_count` in #1025. One occurrence should have been replaced with adding an outstanding request. Normally this isn't an issue, but it could cause the server connection not to be closed if the client disconnects before the auth_query is finished running. To be clear, #1025 did not introduce a regression in this respect. Because `expect_rfq_count` being non-zero on would not cause a server connection closure when the server was released.
In #845 full tracking of expected responses was implemented. This turned out to have bugs when sending
COPY FROM STDINqueries using the extended protocol. The protocol explicitly allows sendingSyncmessages after sending anExecutemessage for aCOPY FROM STDINcommand. Such Sync messages are ignored by the server until a CopyDone or CopyFail message is received. The new command queue tracking did not take this into account, and was incorrectly expecting more ReadyForQuery messages from the server.This could lead to two problems for the server connection on which the
COPY FROM STDINwas sent:max_prepared_statementswas non-zero, then clients might receive ParseComplete and CloseComplete responses in the wrong order. This wouldn't result in wrong behaviour by the server, but the client might get confused and close the connection.This PR fixes these issues. It also removes the rfq_count tracking, since it's now only keeping track of a strict subset of what the outstanding request queue was tracking.
Fixes #1023
Fixes #1024