[close #600] `ScanIterator` missing fetch the region keys because the wrong limit setting

Signed-off-by: Yi Xie <xieyi01@rd.netease.com>

Co-authored-by: Yi Xie <xieyi01@rd.netease.com>
This commit is contained in:
xieyi888 2022-05-13 00:07:29 +08:00 committed by GitHub
parent 660199a2d2
commit 3163793311
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 6 deletions

View File

@ -91,15 +91,13 @@ public abstract class ScanIterator implements Iterator<Kvrpcpb.KvPair> {
// Session should be single-threaded itself
// so that we don't worry about conf change in the middle
// of a transaction. Otherwise, below code might lose data
if (currentCache.size() < limit) {
int scanLimit = Math.min(limit, conf.getScanBatchSize());
if (currentCache.size() < scanLimit) {
startKey = curRegionEndKey;
lastKey = Key.toRawKey(curRegionEndKey);
} else if (currentCache.size() > limit) {
} else if (currentCache.size() > scanLimit) {
throw new IndexOutOfBoundsException(
"current cache size = "
+ currentCache.size()
+ ", larger than "
+ conf.getScanBatchSize());
"current cache size = " + currentCache.size() + ", larger than " + scanLimit);
} else {
// Start new scan from exact next key in current region
lastKey = Key.toRawKey(currentCache.get(currentCache.size() - 1).getKey());