sql: fix bug with multi-statement implicit txn schema changes and Bind#92300
Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom Nov 22, 2022
Merged
Conversation
For legacy reasons, we were resetting the descriptor collection state in Bind if we thought we were not in a transaction. Since cockroachdb#76792, we're always in a transaction. You might think that'd mean that the logic would not run. Sadly, for other still unclear reasons, when in an implicit transaction `(*connExecutor).getTransactionState()` returns `NoTxnStateStr`. The end result was that we'd erroneously reset our descriptor state in the middle of a multi- statement implicit transaction if bind was invoked. Fixes cockroachdb#82921 Release note (bug fix): Fixed a bug which could lead to errors when running multiple schema change statements in a single command using a driver that uses the extended pgwire protocol internally (Npgsql in .Net as an example). These errors would have the form "attempted to update job for mutation 2, but job already exists with mutation 1".
Member
rafiss
approved these changes
Nov 22, 2022
Collaborator
rafiss
left a comment
There was a problem hiding this comment.
wow nice find
Reviewable status:
complete! 0 of 0 LGTMs obtained (waiting on @ajwerner)
-- commits line 7 at r1:
my educated guess for the weird getTransactionState() behavior is that it's purely to implement show transaction_status. but it was a mistake to implement show transaction_status that way; maybe it should use an observer statement instead
Contributor
Author
|
TFTR! bors r+ |
Contributor
|
Build succeeded: |
This was referenced Nov 22, 2022
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
For legacy reasons, we were resetting the descriptor collection state in Bind if we thought we were not in a transaction. Since #76792, we're always in a transaction. You might think that'd mean that the logic would not run. Sadly, for other still unclear reasons, when in an implicit transaction
(*connExecutor).getTransactionState()returnsNoTxnStateStr. The end result was that we'd erroneously reset our descriptor state in the middle of a multi- statement implicit transaction if bind was invoked.Fixes #82921
Release note (bug fix): Fixed a bug which could lead to errors when running multiple schema change statements in a single command using a driver that uses the extended pgwire protocol internally (Npgsql in .Net as an example). These errors would have the form "attempted to update job for mutation 2, but job already exists with mutation 1".