mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 00:30:49 +00:00
Merge pull request #63816 from ClickHouse/fix-race-log-entry-data
Fix race in `ReplicatedMergeTreeLogEntryData`
This commit is contained in:
commit
3d76de3fec
39
src/Common/CopyableAtomic.h
Normal file
39
src/Common/CopyableAtomic.h
Normal file
@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#include <atomic>
|
||||
#include <utility>
|
||||
|
||||
namespace DB
|
||||
{
|
||||
|
||||
template <typename T>
|
||||
struct CopyableAtomic
|
||||
{
|
||||
CopyableAtomic(const CopyableAtomic & other)
|
||||
: value(other.value.load())
|
||||
{}
|
||||
|
||||
explicit CopyableAtomic(T && value_)
|
||||
: value(std::forward<T>(value_))
|
||||
{}
|
||||
|
||||
CopyableAtomic & operator=(const CopyableAtomic & other)
|
||||
{
|
||||
value = other.value.load();
|
||||
return *this;
|
||||
}
|
||||
|
||||
CopyableAtomic & operator=(bool value_)
|
||||
{
|
||||
value = value_;
|
||||
return *this;
|
||||
}
|
||||
|
||||
explicit operator T() const { return value; }
|
||||
|
||||
const T & getValue() const { return value; }
|
||||
|
||||
std::atomic<T> value;
|
||||
};
|
||||
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Common/CopyableAtomic.h>
|
||||
#include <Common/Exception.h>
|
||||
#include <Common/ZooKeeper/Types.h>
|
||||
#include <base/types.h>
|
||||
@ -9,7 +10,6 @@
|
||||
#include <Storages/MergeTree/MergeTreeDataFormatVersion.h>
|
||||
#include <Disks/IDisk.h>
|
||||
|
||||
#include <mutex>
|
||||
#include <condition_variable>
|
||||
|
||||
|
||||
@ -174,7 +174,7 @@ struct ReplicatedMergeTreeLogEntryData
|
||||
size_t quorum = 0;
|
||||
|
||||
/// Used only in tests for permanent fault injection for particular queue entry.
|
||||
bool fault_injected = false;
|
||||
CopyableAtomic<bool> fault_injected{false};
|
||||
|
||||
/// If this MUTATE_PART entry caused by alter(modify/drop) query.
|
||||
bool isAlterMutation() const
|
||||
|
Loading…
Reference in New Issue
Block a user