Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix panic when region is not found on TiFlash's side in tryFlushData #5603

Merged
merged 7 commits into from
Aug 11, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions dbms/src/Storages/Transaction/KVStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,15 @@ bool KVStore::tryFlushRegionData(UInt64 region_id, bool try_until_succeed, TMTCo
{
auto region_task_lock = region_manager.genRegionTaskLock(region_id);
const RegionPtr curr_region_ptr = getRegion(region_id);
if (curr_region_ptr == nullptr)
CalvinNeo marked this conversation as resolved.
Show resolved Hide resolved
{
/// If we can't find region here, we return true so proxy can trigger a CompactLog.
/// The triggered CompactLog will be handled by `handleUselessAdminRaftCmd`,
/// and result in a `EngineStoreApplyRes::NotFound`.
/// Proxy will print `region not found in engine-store, maybe have exec `RemoveNode` first`.
CalvinNeo marked this conversation as resolved.
Show resolved Hide resolved
LOG_FMT_WARNING(log, "region {} [index: {}, term {}], not exist when flushing, maybe have exec `RemoveNode` first", region_id, index, term);
return true;
JaySon-Huang marked this conversation as resolved.
Show resolved Hide resolved
}
return canFlushRegionDataImpl(curr_region_ptr, true, try_until_succeed, tmt, region_task_lock, index, term);
}

Expand Down
2 changes: 2 additions & 0 deletions dbms/src/Storages/Transaction/tests/gtest_kvstore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,8 @@ void RegionKVStoreTest::testKVStore()
ASSERT_EQ(kvs.needFlushRegionData(19, ctx.getTMTContext()), true);
// Force flush until succeed only for testing.
ASSERT_EQ(kvs.tryFlushRegionData(19, true, ctx.getTMTContext(), 0, 0), true);
// Non existing region.
ASSERT_EQ(kvs.tryFlushRegionData(1999, true, ctx.getTMTContext(), 0, 0), true);
}
}

Expand Down