Fix race in system.parts and system.parts_columns

This commit is contained in:
Alexey Milovidov 2022-12-31 15:07:26 +01:00
parent 26eb2f57e1
commit 3a5cea8281
2 changed files with 6 additions and 3 deletions

View File

@ -1851,7 +1851,7 @@ void MergeTreeData::removePartsFinally(const MergeTreeData::DataPartsVector & pa
auto it = data_parts_by_info.find(part->info);
if (it == data_parts_by_info.end())
throw Exception("Deleting data part " + part->name + " doesn't exist", ErrorCodes::LOGICAL_ERROR);
throw Exception(ErrorCodes::LOGICAL_ERROR, "Deleting data part {} doesn't exist", part->name);
(*it)->assertState({DataPartState::Deleting});

View File

@ -193,9 +193,12 @@ void StorageSystemPartsColumns::processNextStorage(
columns[res_index++]->insert(part->getDataPartStorage().getDiskName());
if (columns_mask[src_index++])
{
// The full path changes at clean up thread under deleting state, do not read it, avoid the race
if (part_state != State::Deleting)
/// The full path changes at clean up thread, so do not read it if parts can be deleted, avoid the race.
if (part->isStoredOnDisk()
&& part_state != State::Deleting && part_state != State::DeleteOnDestroy && part_state != State::Temporary)
{
columns[res_index++]->insert(part->getDataPartStorage().getFullPath());
}
else
columns[res_index++]->insertDefault();
}