From 887b2a7a490c7be337ad92848cd6221c9185eb37 Mon Sep 17 00:00:00 2001 From: lidezhu Date: Thu, 23 Jun 2022 23:57:14 +0800 Subject: [PATCH] check return value of tryFlushRegionCacheInStorage --- dbms/src/Storages/Transaction/ApplySnapshot.cpp | 15 ++++++++++++--- dbms/src/Storages/Transaction/KVStore.cpp | 7 +++++-- dbms/src/Storages/Transaction/RegionTable.cpp | 5 ++++- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/dbms/src/Storages/Transaction/ApplySnapshot.cpp b/dbms/src/Storages/Transaction/ApplySnapshot.cpp index 2df95fead93..8e789501ea7 100644 --- a/dbms/src/Storages/Transaction/ApplySnapshot.cpp +++ b/dbms/src/Storages/Transaction/ApplySnapshot.cpp @@ -85,7 +85,10 @@ void KVStore::checkAndApplySnapshot(const RegionPtrWrap & new_region, TMTContext auto region_lock = region_manager.genRegionTaskLock(old_region->id()); old_region->setStateApplying(); tmt.getRegionTable().tryFlushRegion(old_region, false); - tryFlushRegionCacheInStorage(tmt, *old_region, log); + while (!tryFlushRegionCacheInStorage(tmt, *old_region, log)) + { + + } persistRegion(*old_region, region_lock, "save previous region before apply"); } } @@ -206,7 +209,10 @@ void KVStore::onSnapshot(const RegionPtrWrap & new_region_wrap, RegionPtr old_re std::lock_guard lock(bg_gc_region_data_mutex); bg_gc_region_data.push_back(std::move(tmp)); } - tryFlushRegionCacheInStorage(tmt, *new_region_wrap, log); + while (!tryFlushRegionCacheInStorage(tmt, *new_region_wrap, log)) + { + + } } catch (...) { @@ -491,7 +497,10 @@ EngineStoreApplyRes KVStore::handleIngestSST(UInt64 region_id, const SSTViewVec try { tmt.getRegionTable().tryFlushRegion(region, false); - tryFlushRegionCacheInStorage(tmt, *region, log); + while (!tryFlushRegionCacheInStorage(tmt, *region, log)) + { + + } } catch (Exception & e) { diff --git a/dbms/src/Storages/Transaction/KVStore.cpp b/dbms/src/Storages/Transaction/KVStore.cpp index 43c14dd65a1..ba0e8b3e87e 100644 --- a/dbms/src/Storages/Transaction/KVStore.cpp +++ b/dbms/src/Storages/Transaction/KVStore.cpp @@ -139,7 +139,7 @@ bool KVStore::tryFlushRegionCacheInStorage(TMTContext & tmt, const Region & regi "tryFlushRegionCacheInStorage can not get table for region {} with table id {}, ignored", region.toString(), table_id); - return false; + return true; } try @@ -462,7 +462,10 @@ EngineStoreApplyRes KVStore::handleAdminRaftCmd(raft_cmdpb::AdminRequest && requ }; const auto persist_and_sync = [&](const Region & region) { - tryFlushRegionCacheInStorage(tmt, region, log); + while (!tryFlushRegionCacheInStorage(tmt, region, log)) + { + + } persistRegion(region, region_task_lock, "admin raft cmd"); }; diff --git a/dbms/src/Storages/Transaction/RegionTable.cpp b/dbms/src/Storages/Transaction/RegionTable.cpp index 2dee0bc3362..1edb464e8ee 100644 --- a/dbms/src/Storages/Transaction/RegionTable.cpp +++ b/dbms/src/Storages/Transaction/RegionTable.cpp @@ -132,7 +132,10 @@ RegionDataReadInfoList RegionTable::flushRegion(const RegionPtrWithBlock & regio { if (try_persist) { - KVStore::tryFlushRegionCacheInStorage(tmt, *region, log); + while (!KVStore::tryFlushRegionCacheInStorage(tmt, *region, log)) + { + + } tmt.getKVStore()->tryPersist(region->id()); } }