Skip to content

Commit

Permalink
kvcoord: unify the way we handle retryable errors
Browse files Browse the repository at this point in the history
Instead of calling handleRetryableErrLocked() we did similar work
when the transaction sees a retryable error from a heartbeat failure.

Instead, it's better to call the existing handleRetryableErrLocked()
to take care of those errors in one place.

Release note: None
  • Loading branch information
lidorcarmel authored and RajivTS committed Mar 6, 2022
1 parent 3a7d350 commit b171b52
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pkg/kv/kvclient/kvcoord/txn_coord_sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ func (tc *TxnCoordSender) maybeRejectClientLocked(
// The transaction heartbeat observed an aborted transaction record and
// this was not due to a synchronous transaction commit and transaction
// record garbage collection.
// See the comment on txnHeartbeater.mu.finalizedStatus for more details.
// See the comment on txnHeartbeater.mu.finalObservedStatus for more details.
abortedErr := roachpb.NewErrorWithTxn(
roachpb.NewTransactionAbortedError(roachpb.ABORT_REASON_CLIENT_REJECT), &tc.mu.txn)
if tc.typ == kv.LeafTxn {
Expand All @@ -721,10 +721,7 @@ func (tc *TxnCoordSender) maybeRejectClientLocked(
return abortedErr
}
// Root txns handle retriable errors.
newTxn := roachpb.PrepareTransactionForRetry(
ctx, abortedErr, roachpb.NormalUserPriority, tc.clock)
return roachpb.NewError(roachpb.NewTransactionRetryWithProtoRefreshError(
abortedErr.String(), tc.mu.txn.ID, newTxn))
return roachpb.NewError(tc.handleRetryableErrLocked(ctx, abortedErr))
case protoStatus != roachpb.PENDING || hbObservedStatus != roachpb.PENDING:
// The transaction proto is in an unexpected state.
return roachpb.NewErrorf(
Expand Down

0 comments on commit b171b52

Please sign in to comment.