diff --git a/internal/locate/region_cache.go b/internal/locate/region_cache.go index 52e8e6fae..3d4da94d2 100644 --- a/internal/locate/region_cache.go +++ b/internal/locate/region_cache.go @@ -998,7 +998,7 @@ func (l *KeyLocation) locateBucket(key []byte) *Bucket { keys := l.Buckets.GetKeys() searchLen := len(keys) - 1 i, found := slices.BinarySearchFunc(keys, key, func(a, b []byte) int { - return bytes.Compare(a, b) + return -bytes.Compare(a, b) }) // buckets contains region's start/end key, so i==0 means it can't find a suitable bucket