Skip to content

Commit

Permalink
Merge branch 'release-5.0' into cherry-pick-4955-to-release-5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lidezhu authored Jun 2, 2022
2 parents ce59f9a + 8c0492f commit 6bdafaa
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions dbms/src/Storages/Transaction/ApplySnapshot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,10 +151,22 @@ void KVStore::onSnapshot(const RegionPtrWithBlock & new_region_wrap, RegionPtr o
// Acquire `drop_lock` so that no other threads can drop the storage. `alter_lock` is not required.
auto table_lock = storage->lockForShare(getThreadName());
auto dm_storage = std::dynamic_pointer_cast<StorageDeltaMerge>(storage);
auto key_range = DM::RowKeyRange::fromRegionRange(
auto new_key_range = DM::RowKeyRange::fromRegionRange(
new_region_wrap->getRange(), table_id, storage->isCommonHandle(), storage->getRowKeyColumnSize());
if (old_region)
{
auto old_key_range = DM::RowKeyRange::fromRegionRange(
old_region->getRange(), table_id, storage->isCommonHandle(), storage->getRowKeyColumnSize());
if (old_key_range != new_key_range)
{
LOG_INFO(log,
"clear region " << region_id << " old range " << old_key_range.toDebugString()
<< " before apply snapshot of new range " << new_key_range.toDebugString());
dm_storage->deleteRange(old_key_range, context.getSettingsRef());
}
}
// Call `deleteRange` to delete data for range
dm_storage->deleteRange(key_range, context.getSettingsRef());
dm_storage->deleteRange(new_key_range, context.getSettingsRef());
}
catch (DB::Exception & e)
{
Expand Down

0 comments on commit 6bdafaa

Please sign in to comment.