proper checking of atomic flags

This commit is contained in:
Anton Popov 2021-12-29 01:03:55 +03:00
parent a83832c03e
commit 4ebf61b809
2 changed files with 4 additions and 9 deletions

View File

@ -141,18 +141,16 @@ void StorageMergeTree::startup()
void StorageMergeTree::flush() void StorageMergeTree::flush()
{ {
if (flush_called) if (flush_called.exchange(true))
return; return;
flush_called = true;
flushAllInMemoryPartsIfNeeded(); flushAllInMemoryPartsIfNeeded();
} }
void StorageMergeTree::shutdown() void StorageMergeTree::shutdown()
{ {
if (shutdown_called) if (shutdown_called.exchange(true))
return; return;
shutdown_called = true;
/// Unlock all waiting mutations /// Unlock all waiting mutations
{ {

View File

@ -4122,20 +4122,17 @@ void StorageReplicatedMergeTree::startup()
void StorageReplicatedMergeTree::flush() void StorageReplicatedMergeTree::flush()
{ {
if (flush_called) if (flush_called.exchange(true))
return; return;
flush_called = true;
flushAllInMemoryPartsIfNeeded(); flushAllInMemoryPartsIfNeeded();
} }
void StorageReplicatedMergeTree::shutdown() void StorageReplicatedMergeTree::shutdown()
{ {
if (shutdown_called) if (shutdown_called.exchange(true))
return; return;
shutdown_called = true;
/// Cancel fetches, merges and mutations to force the queue_task to finish ASAP. /// Cancel fetches, merges and mutations to force the queue_task to finish ASAP.
fetcher.blocker.cancelForever(); fetcher.blocker.cancelForever();
merger_mutator.merges_blocker.cancelForever(); merger_mutator.merges_blocker.cancelForever();