diff --git a/src/Storages/StorageMergeTree.cpp b/src/Storages/StorageMergeTree.cpp index 02ea036c8ea..d14ee672727 100644 --- a/src/Storages/StorageMergeTree.cpp +++ b/src/Storages/StorageMergeTree.cpp @@ -141,18 +141,16 @@ void StorageMergeTree::startup() void StorageMergeTree::flush() { - if (flush_called) + if (flush_called.exchange(true)) return; - flush_called = true; flushAllInMemoryPartsIfNeeded(); } void StorageMergeTree::shutdown() { - if (shutdown_called) + if (shutdown_called.exchange(true)) return; - shutdown_called = true; /// Unlock all waiting mutations { diff --git a/src/Storages/StorageReplicatedMergeTree.cpp b/src/Storages/StorageReplicatedMergeTree.cpp index a46a7c2f66f..5f829db72f8 100644 --- a/src/Storages/StorageReplicatedMergeTree.cpp +++ b/src/Storages/StorageReplicatedMergeTree.cpp @@ -4122,20 +4122,17 @@ void StorageReplicatedMergeTree::startup() void StorageReplicatedMergeTree::flush() { - if (flush_called) + if (flush_called.exchange(true)) return; - flush_called = true; flushAllInMemoryPartsIfNeeded(); } void StorageReplicatedMergeTree::shutdown() { - if (shutdown_called) + if (shutdown_called.exchange(true)) return; - shutdown_called = true; - /// Cancel fetches, merges and mutations to force the queue_task to finish ASAP. fetcher.blocker.cancelForever(); merger_mutator.merges_blocker.cancelForever();