Skip to content

Commit

Permalink
batcheval: add TODO to improve Refresh{Range}Request
Browse files Browse the repository at this point in the history
Also improve a comment.

Release note: None
  • Loading branch information
nvanbenschoten committed Feb 5, 2019
1 parent ab23010 commit 29149ac
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions pkg/storage/batcheval/cmd_refresh.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,17 @@ func Refresh(
if err != nil {
return result.Result{}, err
} else if val != nil {
// TODO(nvanbenschoten): This is pessimistic. We only need to check
// !ts.Less(h.Txn.PrevRefreshTimestamp)
// This could avoid failed refreshes due to requests performed after
// earlier refreshes.
if ts := val.Timestamp; !ts.Less(h.Txn.OrigTimestamp) {
return result.Result{}, errors.Errorf("encountered recently written key %s @%s", args.Key, ts)
}
}

// Now, check if the intent was written earlier than the command's timestamp
// and was not owned by this transaction.
// Check if an intent which is not owned by this transaction was written
// at or beneath the refresh timestamp.
if intent != nil && intent.Txn.ID != h.Txn.ID {
return result.Result{}, errors.Errorf("encountered recently written intent %s @%s",
intent.Span.Key, intent.Txn.Timestamp)
Expand Down
8 changes: 6 additions & 2 deletions pkg/storage/batcheval/cmd_refresh_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ func RefreshRange(
Inconsistent: true,
Tombstones: true,
}, func(kv roachpb.KeyValue) (bool, error) {
// TODO(nvanbenschoten): This is pessimistic. We only need to check
// !ts.Less(h.Txn.PrevRefreshTimestamp)
// This could avoid failed refreshes due to requests performed after
// earlier refreshes.
if ts := kv.Value.Timestamp; !ts.Less(h.Txn.OrigTimestamp) {
return true, errors.Errorf("encountered recently written key %s @%s", kv.Key, ts)
}
Expand All @@ -61,8 +65,8 @@ func RefreshRange(
return result.Result{}, err
}

// Now, check intents slice for any which were written earlier than
// the command's timestamp, not owned by this transaction.
// Check if any intents which are not owned by this transaction were written
// at or beneath the refresh timestamp.
for _, i := range intents {
// Ignore our own intents.
if i.Txn.ID == h.Txn.ID {
Expand Down

0 comments on commit 29149ac

Please sign in to comment.