Skip to content

Commit

Permalink
Add more information when read index fail (#5526)
Browse files Browse the repository at this point in the history
close #5525
  • Loading branch information
CalvinNeo authored Aug 5, 2022
1 parent 0fb8f41 commit 97fa91f
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions dbms/src/Storages/Transaction/LearnerRead.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,15 +311,15 @@ LearnerReadSnapshot doLearnerRead(
}
}

auto handle_wait_timeout_region = [&unavailable_regions, for_batch_cop](const DB::RegionID region_id) {
auto handle_wait_timeout_region = [&unavailable_regions, for_batch_cop](const DB::RegionID region_id, UInt64 index) {
if (!for_batch_cop)
{
// If server is being terminated / time-out, add the region_id into `unavailable_regions` to other store.
unavailable_regions.add(region_id, RegionException::RegionReadStatus::NOT_FOUND);
return;
}
// TODO: Maybe collect all the Regions that happen wait index timeout instead of just throwing one Region id
throw TiFlashException(fmt::format("Region {} is unavailable", region_id), Errors::Coprocessor::RegionError);
throw TiFlashException(fmt::format("Region {} is unavailable at {}", region_id, index), Errors::Coprocessor::RegionError);
};
const auto wait_index_timeout_ms = tmt.waitIndexTimeout();
for (size_t region_idx = region_begin_idx, read_index_res_idx = 0; region_idx < region_end_idx; ++region_idx, ++read_index_res_idx)
Expand All @@ -342,7 +342,7 @@ LearnerReadSnapshot doLearnerRead(
auto [wait_res, time_cost] = region->waitIndex(index_to_wait, tmt.waitIndexTimeout(), [&tmt]() { return tmt.checkRunning(); });
if (wait_res != WaitIndexResult::Finished)
{
handle_wait_timeout_region(region_to_query.region_id);
handle_wait_timeout_region(region_to_query.region_id, index_to_wait);
continue;
}
if (time_cost > 0)
Expand All @@ -357,7 +357,7 @@ LearnerReadSnapshot doLearnerRead(
// for Regions one by one.
if (!region->checkIndex(index_to_wait))
{
handle_wait_timeout_region(region_to_query.region_id);
handle_wait_timeout_region(region_to_query.region_id, index_to_wait);
continue;
}
}
Expand Down

0 comments on commit 97fa91f

Please sign in to comment.