Skip to content

Commit

Permalink
storage: don't check txn deadline twice in isOnePhaseCommit
Browse files Browse the repository at this point in the history
As of cockroachdb#35284, this was already checked by IsEndTransactionTriggeringRetryError.

Release note: None
  • Loading branch information
nvanbenschoten committed Sep 6, 2019
1 parent 5282fd3 commit adbc415
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
20 changes: 9 additions & 11 deletions pkg/storage/batcheval/cmd_end_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,16 @@ func IsEndTransactionTriggeringRetryError(
retry, reason = false, 0
}

if !retry {
if IsEndTransactionExceedingDeadline(txn.Timestamp, args) {
exceededBy := txn.Timestamp.GoTime().Sub(args.Deadline.GoTime())
fromStart := txn.Timestamp.GoTime().Sub(txn.OrigTimestamp.GoTime())
extraMsg = fmt.Sprintf(
"txn timestamp pushed too much; deadline exceeded by %s (%s > %s), "+
"original timestamp %s ago (%s)",
exceededBy, txn.Timestamp, args.Deadline, fromStart, txn.OrigTimestamp)
retry, reason = true, roachpb.RETRY_COMMIT_DEADLINE_EXCEEDED
}
// However, a transaction must obey its deadline, if set.
if !retry && IsEndTransactionExceedingDeadline(txn.Timestamp, args) {
exceededBy := txn.Timestamp.GoTime().Sub(args.Deadline.GoTime())
fromStart := txn.Timestamp.GoTime().Sub(txn.OrigTimestamp.GoTime())
extraMsg = fmt.Sprintf(
"txn timestamp pushed too much; deadline exceeded by %s (%s > %s), "+
"original timestamp %s ago (%s)",
exceededBy, txn.Timestamp, args.Deadline, fromStart, txn.OrigTimestamp)
retry, reason = true, roachpb.RETRY_COMMIT_DEADLINE_EXCEEDED
}

return retry, reason, extraMsg
}

Expand Down
3 changes: 0 additions & 3 deletions pkg/storage/replica_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -448,9 +448,6 @@ func isOnePhaseCommit(ba *roachpb.BatchRequest) bool {
}
arg, _ := ba.GetArg(roachpb.EndTransaction)
etArg := arg.(*roachpb.EndTransactionRequest)
if batcheval.IsEndTransactionExceedingDeadline(ba.Txn.Timestamp, etArg) {
return false
}
if retry, _, _ := batcheval.IsEndTransactionTriggeringRetryError(ba.Txn, etArg); retry {
return false
}
Expand Down

0 comments on commit adbc415

Please sign in to comment.