Merge pull request #6583 from yandex/fix-false-race-condition-on-frozen-field

Fixed false data race in "MergeTreeDataPart::is_frozen" field
This commit is contained in:
alexey-milovidov 2019-08-21 23:12:34 +03:00 committed by GitHub
commit 4a54f3d7b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -2876,7 +2876,7 @@ void MergeTreeData::freezePartitionsByMatcher(MatcherFn matcher, const String &
String backup_part_absolute_path = part_absolute_path;
backup_part_absolute_path.replace(0, clickhouse_path.size(), backup_path);
localBackup(part_absolute_path, backup_part_absolute_path);
part->is_frozen = true;
part->is_frozen.store(true, std::memory_order_relaxed);
++parts_processed;
}

View File

@ -94,8 +94,8 @@ struct MergeTreeDataPart
/// If true it means that there are no ZooKeeper node for this part, so it should be deleted only from filesystem
bool is_duplicate = false;
/// Frozen by ALTER TABLE ... FREEZE ...
mutable bool is_frozen = false;
/// Frozen by ALTER TABLE ... FREEZE ... It is used for information purposes in system.parts table.
mutable std::atomic<bool> is_frozen {false};
/**
* Part state is a stage of its lifetime. States are ordered and state of a part could be increased only.

View File

@ -103,7 +103,7 @@ void StorageSystemParts::processNextStorage(MutableColumns & columns_, const Sto
columns_[i++]->insert(static_cast<UInt64>(part->info.getDataVersion()));
columns_[i++]->insert(part->getIndexSizeInBytes());
columns_[i++]->insert(part->getIndexSizeInAllocatedBytes());
columns_[i++]->insert(part->is_frozen);
columns_[i++]->insert(part->is_frozen.load(std::memory_order_relaxed));
columns_[i++]->insert(info.database);
columns_[i++]->insert(info.table);