fix bug introduced by #1200 (#1204)

Signed-off-by: SeaRise <hhssearise@foxmail.com>
This commit is contained in:
SeaRise 2024-03-05 16:55:06 +08:00 committed by GitHub
parent 2b14d14975
commit 3625fc04d0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 2 additions and 19 deletions

View File

@ -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