diff --git a/pkg/storage/batcheval/cmd_refresh.go b/pkg/storage/batcheval/cmd_refresh.go index 65069730f01d..54add041f2cf 100644 --- a/pkg/storage/batcheval/cmd_refresh.go +++ b/pkg/storage/batcheval/cmd_refresh.go @@ -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) diff --git a/pkg/storage/batcheval/cmd_refresh_range.go b/pkg/storage/batcheval/cmd_refresh_range.go index 95b70f34d7fc..f96276a70b6b 100644 --- a/pkg/storage/batcheval/cmd_refresh_range.go +++ b/pkg/storage/batcheval/cmd_refresh_range.go @@ -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) } @@ -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 {