-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sql: fix auto-retry behavior with autocommit_before_ddl
When the autocommit_before_ddl setting was enabled, we were sending a notice to the client without any buffering. This prevents auto-retry logic for retriable errors from kicking in, since if results have already sent to the client, it's not safe to retry the current statement. The fix is to buffer the notice for sending instead. It will get sent whenever results are flushed back to the client. In order to achieve this, I changed the SendClientNotice function so that it does not immediately flush the notice. Instead, the notice will now get sent whenever the connection is flushed, like when the results are complete or when a Flush message is received. The existing BufferClientNotice function is not sufficient since that only buffers notices in the command result, and that buffer is discarded due to how the connExecutor state transitions are defined. Namely, the connExecutor will execute the schema change command twice: once to autocommit the current transaction, and another time to run the schema change. To avoid losing the notice from the autocommit, it must be buffered all the way into the client connection, and not just the command result. Running with this patch makes logic tests less flaky, since schema changes that encounter retryable errors are way more likely to be able to be automatically retried now. This allows us to remove the testing knob that overrode the transaction liveness threshold. I verified the flakiness is gone by using: ``` ./dev testlogic ccl --config=3node-tenant --stress --ignore-cache ``` Release note (bug fix): Fixed a bug that prevented transaction retry errors encountered during implicit transactions from being automatically retried internally if the autocommit_before_ddl session variable was enabled and the statement was a schema change.
- Loading branch information
Showing
13 changed files
with
125 additions
and
61 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.