Skip to content

Commit

Permalink
Merge pull request #109031 from cockroachdb/blathers/backport-release…
Browse files Browse the repository at this point in the history
…-23.1.9-rc-107737

release-23.1.9-rc: kv: don't log stack trace on async rollback of committed txn
  • Loading branch information
nvanbenschoten authored Aug 18, 2023
2 parents 8ea01f0 + 3dc8d96 commit 2ce2de1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/kv/kvclient/kvcoord/txn_coord_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,8 @@ func (tc *TxnCoordSender) maybeRejectIncompatibleRequest(
func (tc *TxnCoordSender) maybeRejectClientLocked(
ctx context.Context, ba *kvpb.BatchRequest,
) *kvpb.Error {
if ba != nil && ba.IsSingleAbortTxnRequest() && tc.mu.txn.Status != roachpb.COMMITTED {
rollback := ba != nil && ba.IsSingleAbortTxnRequest()
if rollback && tc.mu.txn.Status != roachpb.COMMITTED {
// As a special case, we allow rollbacks to be sent at any time. Any
// rollback attempt moves the TxnCoordSender state to txnFinalized, but higher
// layers are free to retry rollbacks if they want (and they do, for
Expand All @@ -717,8 +718,13 @@ func (tc *TxnCoordSender) maybeRejectClientLocked(
case txnFinalized:
msg := redact.Sprintf("client already committed or rolled back the transaction. "+
"Trying to execute: %s", ba.Summary())
stack := string(debug.Stack())
log.Errorf(ctx, "%s. stack:\n%s", msg, stack)
if !rollback {
// If the client is trying to do anything other than rollback, it is
// unexpected for it to find the transaction already in a txnFinalized
// state. This may be a bug, so log a stack trace.
stack := string(debug.Stack())
log.Errorf(ctx, "%s. stack:\n%s", msg, stack)
}
reason := kvpb.TransactionStatusError_REASON_UNKNOWN
if tc.mu.txn.Status == roachpb.COMMITTED {
reason = kvpb.TransactionStatusError_REASON_TXN_COMMITTED
Expand Down

0 comments on commit 2ce2de1

Please sign in to comment.