From 63d2350442e82c65dbee0a5784abf2a3677cfca4 Mon Sep 17 00:00:00 2001 From: Nathan VanBenschoten Date: Wed, 26 Dec 2018 16:17:50 -0500 Subject: [PATCH] storage: don't update timestamp cache on scans with limit 0 Not related to #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 --- pkg/storage/replica_tscache.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/pkg/storage/replica_tscache.go b/pkg/storage/replica_tscache.go index 13df5e878395..d59f22c87806 100644 --- a/pkg/storage/replica_tscache.go +++ b/pkg/storage/replica_tscache.go @@ -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. @@ -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