diff --git a/pkg/core/region.go b/pkg/core/region.go index 244fef836f8..caa7148bfff 100644 --- a/pkg/core/region.go +++ b/pkg/core/region.go @@ -1897,7 +1897,17 @@ func scanRegion(regionTree *regionTree, keyRange *KeyRange, limit int, outputMus return nil, err } - if !(exceedLimit()) && len(keyRange.EndKey) > 0 && len(lastRegion.GetEndKey()) > 0 && + if exceedLimit() { + return res, nil + } + + log.Info("just for test", + logutil.ZapRedactStringer("meta-region", RegionToHexMeta(lastRegion.GetMeta())), + zap.ByteString("key-range.start-key", HexRegionKey(keyRange.StartKey)), + zap.ByteString("key-range.end-key", HexRegionKey(keyRange.EndKey)), + ) + + if len(keyRange.EndKey) > 0 && len(lastRegion.GetEndKey()) > 0 && bytes.Compare(lastRegion.GetEndKey(), keyRange.EndKey) < 0 { err = errs.ErrRegionNotAdjacent.FastGen( "key range[%x, %x) found a hole region in the last, the last scanned region is [%x, %x), [%x, %x) is missing", diff --git a/pkg/core/region_test.go b/pkg/core/region_test.go index 845944780e4..ae8f14ce014 100644 --- a/pkg/core/region_test.go +++ b/pkg/core/region_test.go @@ -1166,6 +1166,7 @@ func TestScanRegion(t *testing.T) { re.Len(scanNoError([]byte("a"), []byte("b"), 0), 1) scanError([]byte("a"), []byte("c"), 0) re.Len(scanNoError([]byte("a"), []byte("c"), 1), 1) + scanNoError([]byte("b"), []byte("c"), 0) // region1 | region2 // [a, b) | [b, c)