diff --git a/pkg/kv/kvserver/batcheval/declare.go b/pkg/kv/kvserver/batcheval/declare.go index ba5a1ccd9a2c..8f9e69513c66 100644 --- a/pkg/kv/kvserver/batcheval/declare.go +++ b/pkg/kv/kvserver/batcheval/declare.go @@ -171,7 +171,10 @@ func DeclareKeysForRefresh( func DeclareKeysForBatch( rs ImmutableRangeState, header *kvpb.Header, latchSpans *spanset.SpanSet, ) error { - if header.Txn != nil { + // If the batch is transactional and has acquired locks, we will check if the + // transaction has been aborted during evaluation (see checkIfTxnAborted), so + // declare a read latch on the AbortSpan key. + if header.Txn != nil && header.Txn.IsLocking() { header.Txn.AssertInitialized(context.TODO()) latchSpans.AddNonMVCC(spanset.SpanReadOnly, roachpb.Span{ Key: keys.AbortSpanKey(rs.GetRangeID(), header.Txn.ID),