release-21.2: kvcoord: avoid concurrent rollbacks when making parallel commits explicit #70227
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.
Backport 1/1 commits from #69966 on behalf of @erikgrinaker.
/cc @cockroachdb/release
TxnCoordSender
allowsEndTxn(commit=false)
rollback requests even ifthe transaction state is finalized, since clients can send multiple
rollbacks (e.g. due to context cancellation). However, it allowed this
even when the transaction was committed. This could pass the request
through while the
txnCommitter
was asynchronously making an implicitcommit explicit, which would violate the
txnLockGatekeeper
requirementthat transaction requests are synchronous (non-concurrent) which would
return an unexpected error for the rollback.
This patch rejects additional
EndTxn(commit=false)
requests if thefinalized transaction is known to be committed, to prevent this race
condition. If rejected, the returned error is of the same type that
would be returned by
EndTxn
evaluation, although with a differentmessage string.
Note that even though the returned error should really have
REASON_TXN_COMMITTED
in this case, which is also whattxn.Rollback()
expects in order to omit logging, the current
EndTxn
code incorrectlyreturns
REASON_TXN_UNKNOWN
in this case. This behavior is retained tominimize the change, but should be corrected separately.
Resolves #68643.
Informs #69965.
Release justification: fixes for high-priority or high-severity bugs in existing functionality
Release note: None
Release justification: