Skip to content

Commit

Permalink
roachpb: create IsParallelCommit method on EndTransactionRequest
Browse files Browse the repository at this point in the history
Release note: None
  • Loading branch information
nvanbenschoten committed May 15, 2019
1 parent a010c7d commit 1e58017
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 7 additions & 0 deletions pkg/roachpb/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1102,6 +1102,13 @@ func (r *RefreshRangeRequest) flags() int {
func (*SubsumeRequest) flags() int { return isRead | isAlone | updatesReadTSCache }
func (*RangeStatsRequest) flags() int { return isRead }

// IsParallelCommit returns whether the EndTransaction request is attempting to
// perform a parallel commit. See txn_interceptor_committer.go for a discussion
// about parallel commits.
func (etr *EndTransactionRequest) IsParallelCommit() bool {
return etr.Commit && len(etr.InFlightWrites) > 0
}

// Keys returns credentials in an aws.Config.
func (b *ExportStorage_S3) Keys() *aws.Config {
return &aws.Config{
Expand Down
5 changes: 1 addition & 4 deletions pkg/storage/batcheval/cmd_end_transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,7 @@ func canForwardSerializableTimestamp(txn *roachpb.Transaction, noRefreshSpans bo
// that a transaction move to the STAGING state before committing or
// not.
func needsStaging(args *roachpb.EndTransactionRequest) bool {
if args.Commit {
return len(args.InFlightWrites) > 0
}
return false
return args.IsParallelCommit()
}

const intentResolutionBatchSize = 500
Expand Down
2 changes: 1 addition & 1 deletion pkg/storage/replica_write.go
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ func maybeStripInFlightWrites(ba roachpb.BatchRequest) (roachpb.BatchRequest, er

et := args.(*roachpb.EndTransactionRequest)
otherReqs := ba.Requests[:len(ba.Requests)-1]
if len(et.InFlightWrites) == 0 || !et.Commit || len(otherReqs) == 0 {
if !et.IsParallelCommit() || len(otherReqs) == 0 {
return ba, nil
}

Expand Down

0 comments on commit 1e58017

Please sign in to comment.