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()
{
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
{

View File

@ -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();