mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-22 15:42:02 +00:00
Fix replacing parts with empty
Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
This commit is contained in:
parent
6c3db34aae
commit
ee546fa00a
@ -4244,6 +4244,7 @@ MergeTreeData::PartsToRemoveFromZooKeeper MergeTreeData::removePartsInRangeFromW
|
||||
MergeTreeData::Transaction transaction(*this, NO_TRANSACTION_RAW);
|
||||
renameTempPartAndAdd(new_data_part, transaction, lock); /// All covered parts must be already removed
|
||||
|
||||
transaction.renameParts();
|
||||
/// It will add the empty part to the set of Outdated parts without making it Active (exactly what we need)
|
||||
transaction.rollback(&lock);
|
||||
new_data_part->remove_time.store(0, std::memory_order_relaxed);
|
||||
@ -6669,6 +6670,12 @@ void MergeTreeData::Transaction::clear()
|
||||
precommitted_parts_need_rename.clear();
|
||||
}
|
||||
|
||||
void MergeTreeData::Transaction::renameParts()
|
||||
{
|
||||
for (const auto & part_need_rename : precommitted_parts_need_rename)
|
||||
part_need_rename->renameTo(part_need_rename->name, true);
|
||||
}
|
||||
|
||||
MergeTreeData::DataPartsVector MergeTreeData::Transaction::commit(DataPartsLock * acquired_parts_lock)
|
||||
{
|
||||
DataPartsVector total_covered_parts;
|
||||
@ -6683,8 +6690,7 @@ MergeTreeData::DataPartsVector MergeTreeData::Transaction::commit(DataPartsLock
|
||||
if (part->getDataPartStorage().hasActiveTransaction())
|
||||
part->getDataPartStorage().commitTransaction();
|
||||
|
||||
for (const auto & part_need_rename : precommitted_parts_need_rename)
|
||||
part_need_rename->renameTo(part_need_rename->name, true);
|
||||
renameParts();
|
||||
|
||||
if (txn)
|
||||
{
|
||||
|
@ -255,6 +255,8 @@ public:
|
||||
|
||||
DataPartsVector commit(DataPartsLock * acquired_parts_lock = nullptr);
|
||||
|
||||
void renameParts();
|
||||
|
||||
void addPart(MutableDataPartPtr & part, bool need_rename);
|
||||
|
||||
void rollback(DataPartsLock * lock = nullptr);
|
||||
|
Loading…
Reference in New Issue
Block a user