Skip to content

Commit

Permalink
kvserver/batcheval: add logging to EndTxn tscache protection
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
andreimatei committed Jun 18, 2020
1 parent bd0733d commit b22e924
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_end_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/kv/kvserver/batcheval/cmd_heartbeat_txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
7 changes: 5 additions & 2 deletions pkg/kv/kvserver/batcheval/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b22e924

Please sign in to comment.