Merge pull request #28221 from azat/remove-Temporary-part-fix

Fix removing of parts in a Temporary state
This commit is contained in:
alesapin 2021-08-30 12:39:08 +03:00 committed by GitHub
commit 531079c452
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2593,17 +2593,25 @@ void MergeTreeData::tryRemovePartImmediately(DataPartPtr && part)
LOG_TRACE(log, "Trying to immediately remove part {}", part->getNameWithState());
auto it = data_parts_by_info.find(part->info);
if (it == data_parts_by_info.end() || (*it).get() != part.get())
throw Exception("Part " + part->name + " doesn't exist", ErrorCodes::LOGICAL_ERROR);
if (part->getState() != DataPartState::Temporary)
{
auto it = data_parts_by_info.find(part->info);
if (it == data_parts_by_info.end() || (*it).get() != part.get())
throw Exception("Part " + part->name + " doesn't exist", ErrorCodes::LOGICAL_ERROR);
part.reset();
part.reset();
if (!((*it)->getState() == DataPartState::Outdated && it->unique()))
return;
if (!((*it)->getState() == DataPartState::Outdated && it->unique()))
return;
modifyPartState(it, DataPartState::Deleting);
part_to_delete = *it;
modifyPartState(it, DataPartState::Deleting);
part_to_delete = *it;
}
else
{
part_to_delete = std::move(part);
}
}
try