@@ -273,6 +273,9 @@ func EndTxn(
273
273
274
274
// Fetch existing transaction.
275
275
var existingTxn roachpb.Transaction
276
+ log .VEventf (
277
+ ctx , 2 , "checking to see if transaction record already exists for txn: %s" , h .Txn ,
278
+ )
276
279
recordAlreadyExisted , err := storage .MVCCGetProto (
277
280
ctx , readWriter , key , hlc.Timestamp {}, & existingTxn , storage.MVCCGetOptions {
278
281
ReadCategory : fs .BatchEvalReadCategory ,
@@ -281,6 +284,7 @@ func EndTxn(
281
284
if err != nil {
282
285
return result.Result {}, err
283
286
} else if ! recordAlreadyExisted {
287
+ log .VEvent (ctx , 2 , "no existing txn record found" )
284
288
// No existing transaction record was found - create one by writing it
285
289
// below in updateFinalizedTxn.
286
290
reply .Txn = h .Txn .Clone ()
@@ -290,10 +294,12 @@ func EndTxn(
290
294
// an aborted txn record.
291
295
if args .Commit {
292
296
if err := CanCreateTxnRecord (ctx , cArgs .EvalCtx , reply .Txn ); err != nil {
297
+ log .VEventf (ctx , 2 , "cannot create transaction record: %v" , err )
293
298
return result.Result {}, err
294
299
}
295
300
}
296
301
} else {
302
+ log .VEventf (ctx , 2 , "existing transaction record found: %s" , existingTxn )
297
303
// We're using existingTxn on the reply, although it can be stale
298
304
// compared to the Transaction in the request (e.g. the Sequence,
299
305
// and various timestamps). We must be careful to update it with the
@@ -317,8 +323,11 @@ func EndTxn(
317
323
"already committed" )
318
324
319
325
case roachpb .ABORTED :
326
+ // The transaction has already been aborted by someone else.
327
+ log .VEventf (
328
+ ctx , 2 , "transaction %s found to have be already aborted (by someone else)" , reply .Txn ,
329
+ )
320
330
if ! args .Commit {
321
- // The transaction has already been aborted by other.
322
331
// Do not return TransactionAbortedError since the client anyway
323
332
// wanted to abort the transaction.
324
333
resolvedLocks , _ , externalLocks , err := resolveLocalLocks (ctx , readWriter , cArgs .EvalCtx , ms , args , reply .Txn )
@@ -379,6 +388,7 @@ func EndTxn(
379
388
// not consider the transaction to be performing a parallel commit and
380
389
// potentially already implicitly committed because we know that the
381
390
// transaction restarted since entering the STAGING state.
391
+ log .VEventf (ctx , 2 , "request with newer epoch %d than STAGING txn record; parallel commit must have failed" , h .Txn .Epoch )
382
392
reply .Txn .Status = roachpb .PENDING
383
393
default :
384
394
panic ("unreachable" )
@@ -543,13 +553,18 @@ func EndTxn(
543
553
txnResult .Local .ResolvedLocks = resolvedLocks
544
554
545
555
if reply .Txn .Status == roachpb .COMMITTED {
546
- // Return whether replicated {shared, exclusive} locks were released by
547
- // the committing transaction. If such locks were released, we still
548
- // need to make sure other transactions can't write underneath the
549
- // transaction's commit timestamp to the key spans previously protected
550
- // by the locks. We return the spans on the response and update the
551
- // timestamp cache a few layers above to ensure this.
552
- reply .ReplicatedLocksReleasedOnCommit = releasedReplLocks
556
+ if len (releasedReplLocks ) != 0 {
557
+ // Return that local replicated {shared, exclusive} locks were released by
558
+ // the committing transaction. If such locks were released, we still need
559
+ // to make sure other transactions can't write underneath the
560
+ // transaction's commit timestamp to the key spans previously protected by
561
+ // the locks. We return the spans on the response and update the timestamp
562
+ // cache a few layers above to ensure this.
563
+ reply .ReplicatedLocalLocksReleasedOnCommit = releasedReplLocks
564
+ log .VEventf (
565
+ ctx , 2 , "committed transaction released local replicated shared/exclusive locks" ,
566
+ )
567
+ }
553
568
554
569
// Run the commit triggers if successfully committed.
555
570
triggerResult , err := RunCommitTrigger (
0 commit comments