Skip to content

Commit e2687fc

Browse files
Merge pull request ClickHouse#6513 from yandex/parts-race-condition
Fix race condition in system.parts vs. ALTER
2 parents e7a2565 + af2a947 commit e2687fc

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

dbms/src/Storages/MergeTree/MergeTreeDataPart.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,8 @@ void MergeTreeDataPart::remove() const
409409
#pragma GCC diagnostic push
410410
#pragma GCC diagnostic ignored "-Wunused-variable"
411411
#endif
412+
std::shared_lock<std::shared_mutex> lock(columns_lock);
413+
412414
for (const auto & [file, _] : checksums.files)
413415
{
414416
String path_to_remove = to + "/" + file;

dbms/src/Storages/System/StorageSystemParts.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,11 @@ void StorageSystemParts::processNextStorage(MutableColumns & columns_, const Sto
114114
columns_[i++]->insert(part->stateString());
115115

116116
MinimalisticDataPartChecksums helper;
117-
helper.computeTotalChecksums(part->checksums);
117+
{
118+
/// TODO: MergeTreeDataPart structure is too error-prone.
119+
std::shared_lock<std::shared_mutex> lock(part->columns_lock);
120+
helper.computeTotalChecksums(part->checksums);
121+
}
118122

119123
auto checksum = helper.hash_of_all_files;
120124
columns_[i++]->insert(getHexUIntLowercase(checksum.first) + getHexUIntLowercase(checksum.second));

0 commit comments

Comments
 (0)