Skip to content

Commit

Permalink
storage: don't update timestamp cache on scans with limit 0
Browse files Browse the repository at this point in the history
Not related to cockroachdb#32149.

Before this change, we would treat a scan with limit 0 as a point
lookup when updating the timestamp cache. After the change, we no
longer update the timestamp cache if a scan had a limit of 0 and
never looked at any keys.

Release note: None
  • Loading branch information
nvanbenschoten committed Jul 11, 2019
1 parent 8125e87 commit 63d2350
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions pkg/storage/replica_tscache.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ func (r *Replica) updateTimestampCache(
case *roachpb.ScanRequest:
resp := br.Responses[i].GetInner().(*roachpb.ScanResponse)
if resp.ResumeSpan != nil {
if start.Equal(resp.ResumeSpan.Key) {
// If the forward scan was evaluated with a key limit of zero
// then it will return a resume span equal to its request
// span. In this case, don't update the timestamp cache.
continue
}
// Note that for forward scan, the resume span will start at
// the (last key read).Next(), which is actually the correct
// end key for the span to update the timestamp cache.
Expand All @@ -158,6 +164,12 @@ func (r *Replica) updateTimestampCache(
case *roachpb.ReverseScanRequest:
resp := br.Responses[i].GetInner().(*roachpb.ReverseScanResponse)
if resp.ResumeSpan != nil {
if end.Equal(resp.ResumeSpan.EndKey) {
// If the reverse scan was evaluated with a key limit of zero
// then it will return a resume span equal to its request
// span. In this case, don't update the timestamp cache.
continue
}
// Note that for reverse scans, the resume span's end key is
// an open interval. That means it was read as part of this op
// and won't be read on resume. It is the correct start key for
Expand Down

0 comments on commit 63d2350

Please sign in to comment.