Skip to content

Commit

Permalink
Merge #32211
Browse files Browse the repository at this point in the history
32211: batcheval: Work around time-bound iterator bug in RefreshRange r=benesch a=bdarnell

Updates #28358
Fixes #31823

Release note (bug fix): Fix long stalls that can occur in contended
transactions.

Co-authored-by: Ben Darnell <[email protected]>
  • Loading branch information
craig[bot] and bdarnell committed Nov 12, 2018
2 parents b3ba03f + ad54ae6 commit 21bdbd8
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions pkg/storage/batcheval/cmd_refresh_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,33 @@ func RefreshRange(
if i.Txn.ID == h.Txn.ID {
continue
}

if i.Span.EndKey != nil {
return result.Result{}, errors.Errorf("unexpected range intent from MVCC storage")
}

// HACK(bdarnell): Time-bound iterators can return intents that
// shouldn't be there
// (https://github.com/cockroachdb/cockroach/issues/28358), and
// this can result in stalled traffic when it occurs in this
// method (https://github.com/cockroachdb/cockroach/issues/31823).
// When we get an intent, check with a regular iterator to ensure
// that it's really there.
_, realIntents, err := engine.MVCCGetWithTombstone(
ctx,
batch,
i.Span.Key,
h.Txn.Timestamp,
false, /* consistent */
nil, /* txn */
)
if err != nil {
return result.Result{}, err
}
if len(realIntents) == 0 {
continue
}

// Return an error if an intent was written to the span.
return result.Result{}, errors.Errorf("encountered recently written intent %s @%s",
i.Span.Key, i.Txn.Timestamp)
Expand Down

0 comments on commit 21bdbd8

Please sign in to comment.