mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Merge pull request #9726 from ClickHouse/text-log-fix-race
Fixed race condition in text_log
This commit is contained in:
commit
638d1e6466
@ -71,7 +71,8 @@ void OwnSplitChannel::logSplit(const Poco::Message & msg)
|
||||
|
||||
|
||||
/// Also log to system.text_log table, if message is not too noisy
|
||||
if (text_log_max_priority && msg.getPriority() <= text_log_max_priority)
|
||||
auto text_log_max_priority_loaded = text_log_max_priority.load(std::memory_order_relaxed);
|
||||
if (text_log_max_priority_loaded && msg.getPriority() <= text_log_max_priority_loaded)
|
||||
{
|
||||
TextLogElement elem;
|
||||
|
||||
@ -108,7 +109,7 @@ void OwnSplitChannel::addTextLog(std::shared_ptr<DB::TextLog> log, int max_prior
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(text_log_mutex);
|
||||
text_log = log;
|
||||
text_log_max_priority = max_priority;
|
||||
text_log_max_priority.store(max_priority, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ private:
|
||||
std::mutex text_log_mutex;
|
||||
|
||||
std::weak_ptr<DB::TextLog> text_log;
|
||||
int text_log_max_priority = -1;
|
||||
std::atomic<int> text_log_max_priority = -1;
|
||||
};
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user