Skip to content

Commit 292016e

Browse files
committed
Add missed lock
1 parent bd61b55 commit 292016e

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/Storages/MergeTree/MergeTreeData.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ class MergeTreeData : public IStorage
477477

478478
/// Delete all directories which names begin with "tmp"
479479
/// Set non-negative parameter value to override MergeTreeSettings temporary_directories_lifetime
480-
/// Must be called with locked lockForShare().
480+
/// Must be called with locked lockForShare() because use relative_data_path.
481481
void clearOldTemporaryDirectories(ssize_t custom_directories_lifetime_seconds = -1);
482482

483483
/// After the call to dropAllData() no method can be called.
@@ -487,9 +487,9 @@ class MergeTreeData : public IStorage
487487
/// Drop data directories if they are empty. It is safe to call this method if table creation was unsuccessful.
488488
void dropIfEmpty();
489489

490-
/// Moves the entire data directory.
491-
/// Flushes the uncompressed blocks cache and the marks cache.
492-
/// Must be called with locked lockForShare().
490+
/// Moves the entire data directory. Flushes the uncompressed blocks cache
491+
/// and the marks cache. Must be called with locked lockExclusively()
492+
/// because changes relative_data_path.
493493
void rename(const String & new_table_path, const StorageID & new_table_id) override;
494494

495495
/// Check if the ALTER can be performed:

src/Storages/StorageMergeTree.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -865,8 +865,11 @@ BackgroundProcessingPoolTaskResult StorageMergeTree::mergeMutateTask()
865865
/// Clear old parts. It is unnecessary to do it more than once a second.
866866
if (auto lock = time_after_previous_cleanup.compareAndRestartDeferred(1))
867867
{
868-
clearOldPartsFromFilesystem();
869-
clearOldTemporaryDirectories();
868+
{
869+
auto share_lock = lockForShare(RWLockImpl::NO_QUERY, getSettings()->lock_acquire_timeout_for_background_operations);
870+
clearOldPartsFromFilesystem();
871+
clearOldTemporaryDirectories();
872+
}
870873
clearOldMutations();
871874
}
872875

0 commit comments

Comments
 (0)