Skip to content

Commit

Permalink
opt
Browse files Browse the repository at this point in the history
  • Loading branch information
shiyuhang0 committed Mar 26, 2024
1 parent e4af597 commit adc7e2d
Showing 1 changed file with 29 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -284,28 +284,36 @@ private SelectResponse process(RegionTask regionTask) {
+ remainTasks.size()
+ " tasks not executed due to",
e);
String regionSt = Arrays.toString(region.getStartKey().toByteArray());
String regionEd = Arrays.toString(region.getEndKey().toByteArray());
Long storeId = store == null ? 0 : store.getId();
logger.warn(
String.format(
"region task failed. host:%s region:%s, store: %d. region start key: %s, region end key: %s",
task.getHost(), region.getId(), storeId, regionSt, regionEd));
logger.warn("start to print range");
for (Coprocessor.KeyRange range : ranges) {

// We guess range may exceed bound when codes go to IndexScanIterator. Since it is hard to
// find the root cause, we just log it and retry once here.
// We use splitRangeByRegion method to avoid exceed bound issue. It seems this method can
// split range correctly.
if (e.getMessage().contains("Request range exceeds bound")) {
String regionSt = Arrays.toString(region.getStartKey().toByteArray());
String regionEd = Arrays.toString(region.getEndKey().toByteArray());
Long storeId = store == null ? 0 : store.getId();
logger.warn(
"Sending DAG request with range "
+ Arrays.toString(range.getStart().toByteArray())
+ " to "
+ Arrays.toString(range.getEnd().toByteArray()));
}
if (retryCount < 1) {
retryCount++;
logger.info("Re-splitting region task and retry once");
remainTasks.addAll(
RangeSplitter.newSplitter(clientSession.getTiKVSession().getRegionManager())
.splitRangeByRegion(ranges, storeType));
continue;
String.format(
"region task failed. host:%s region:%s, store: %d. region start key: %s, region end key: %s",
task.getHost(), region.getId(), storeId, regionSt, regionEd));
logger.warn("start to print range");
for (Coprocessor.KeyRange range : ranges) {
logger.warn(
"Sending DAG request with range "
+ Arrays.toString(range.getStart().toByteArray())
+ " to "
+ Arrays.toString(range.getEnd().toByteArray()));
}
if (retryCount < 1) {
retryCount++;
remainTasks.addAll(
RangeSplitter.newSplitter(clientSession.getTiKVSession().getRegionManager())
.splitRangeByRegion(ranges, storeType));
logger.info(
"Re-splitting region task and retry once. Task count: " + remainTasks.size());
continue;
}
}
// Rethrow to upper levels
throw new RegionTaskException("Handle region task failed:", e);
Expand Down

0 comments on commit adc7e2d

Please sign in to comment.