Skip to content

Commit

Permalink
check return value of tryFlushRegionCacheInStorage
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu committed Jun 23, 2022
1 parent e199deb commit 887b2a7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
15 changes: 12 additions & 3 deletions dbms/src/Storages/Transaction/ApplySnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Expand Down Expand Up @@ -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 (...)
{
Expand Down Expand Up @@ -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)
{
Expand Down
7 changes: 5 additions & 2 deletions dbms/src/Storages/Transaction/KVStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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");
};

Expand Down
5 changes: 4 additions & 1 deletion dbms/src/Storages/Transaction/RegionTable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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());
}
}
Expand Down

0 comments on commit 887b2a7

Please sign in to comment.