From 3625fc04d0bdde3ed9e889ea1f43d4781eb2ee1d Mon Sep 17 00:00:00 2001 From: SeaRise Date: Tue, 5 Mar 2024 16:55:06 +0800 Subject: [PATCH] fix bug introduced by #1200 (#1204) Signed-off-by: SeaRise --- internal/locate/region_cache.go | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) diff --git a/internal/locate/region_cache.go b/internal/locate/region_cache.go index d06931bf..a1c0f914 100644 --- a/internal/locate/region_cache.go +++ b/internal/locate/region_cache.go @@ -1178,25 +1178,8 @@ func (b *Bucket) Contains(key []byte) bool { // LocateKeyRange lists region and range that key in [start_key,end_key]. func (c *RegionCache) LocateKeyRange(bo *retry.Backoffer, startKey, endKey []byte) ([]*KeyLocation, error) { var res []*KeyLocation - // 1. find tail regions from cache for { - r := c.tryFindRegionByKey(endKey, true) - if r == nil { - break - } - res = append(res, &KeyLocation{ - Region: r.VerID(), - StartKey: r.StartKey(), - EndKey: r.EndKey(), - Buckets: r.getStore().buckets, - }) - if r.Contains(startKey) { - return res, nil - } - endKey = r.StartKey() - } - for { - // 2. find head regions from cache + // 1. find regions from cache for { r := c.tryFindRegionByKey(startKey, false) if r == nil { @@ -1213,7 +1196,7 @@ func (c *RegionCache) LocateKeyRange(bo *retry.Backoffer, startKey, endKey []byt } startKey = r.EndKey() } - // 3. load remaining regions from pd client + // 2. load remaining regions from pd client batchRegions, err := c.BatchLoadRegionsWithKeyRange(bo, startKey, endKey, defaultRegionsPerBatch) if err != nil { return nil, err