From b22e924fe625d41b8cf0475d3f0ef251b3a7b34a Mon Sep 17 00:00:00 2001 From: Andrei Matei Date: Tue, 16 Jun 2020 15:23:35 -0400 Subject: [PATCH] kvserver/batcheval: add logging to EndTxn tscache protection Release note: None --- pkg/kv/kvserver/batcheval/cmd_end_transaction.go | 2 +- pkg/kv/kvserver/batcheval/cmd_heartbeat_txn.go | 2 +- pkg/kv/kvserver/batcheval/transaction.go | 7 +++++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pkg/kv/kvserver/batcheval/cmd_end_transaction.go b/pkg/kv/kvserver/batcheval/cmd_end_transaction.go index de3c6f7635a3..72e47af3364b 100644 --- a/pkg/kv/kvserver/batcheval/cmd_end_transaction.go +++ b/pkg/kv/kvserver/batcheval/cmd_end_transaction.go @@ -211,7 +211,7 @@ func EndTxn( // to perform this verification for commits. Rollbacks can always write // an aborted txn record. if args.Commit { - if err := CanCreateTxnRecord(cArgs.EvalCtx, reply.Txn); err != nil { + if err := CanCreateTxnRecord(ctx, cArgs.EvalCtx, reply.Txn); err != nil { return result.Result{}, err } } diff --git a/pkg/kv/kvserver/batcheval/cmd_heartbeat_txn.go b/pkg/kv/kvserver/batcheval/cmd_heartbeat_txn.go index 868f9801e67b..96fb31572245 100644 --- a/pkg/kv/kvserver/batcheval/cmd_heartbeat_txn.go +++ b/pkg/kv/kvserver/batcheval/cmd_heartbeat_txn.go @@ -66,7 +66,7 @@ func HeartbeatTxn( txn = *h.Txn // Verify that it is safe to create the transaction record. - if err := CanCreateTxnRecord(cArgs.EvalCtx, &txn); err != nil { + if err := CanCreateTxnRecord(ctx, cArgs.EvalCtx, &txn); err != nil { return result.Result{}, err } } diff --git a/pkg/kv/kvserver/batcheval/transaction.go b/pkg/kv/kvserver/batcheval/transaction.go index a1993fb7888b..6561f71dcf59 100644 --- a/pkg/kv/kvserver/batcheval/transaction.go +++ b/pkg/kv/kvserver/batcheval/transaction.go @@ -126,14 +126,17 @@ func CanPushWithPriority(pusher, pushee *roachpb.Transaction) bool { // CanCreateTxnRecord determines whether a transaction record can be created for // the provided transaction. If not, the function will return an error. If so, // the function may modify the provided transaction. -func CanCreateTxnRecord(rec EvalContext, txn *roachpb.Transaction) error { +func CanCreateTxnRecord(ctx context.Context, rec EvalContext, txn *roachpb.Transaction) error { // Provide the transaction's minimum timestamp. The transaction could not // have written a transaction record previously with a timestamp below this. ok, minCommitTS, reason := rec.CanCreateTxnRecord(txn.ID, txn.Key, txn.MinTimestamp) if !ok { + log.VEventf(ctx, 2, "txn tombstone present; transaction has been aborted") return roachpb.NewTransactionAbortedError(reason) } - txn.WriteTimestamp.Forward(minCommitTS) + if bumped := txn.WriteTimestamp.Forward(minCommitTS); bumped { + log.VEventf(ctx, 2, "write timestamp bumped by txn tombstone to: %s", txn.WriteTimestamp) + } return nil }