Fixed race condition in text_log

This commit is contained in:
Alexey Milovidov 2020-03-18 14:59:40 +03:00
parent 48a2b46499
commit 36aab47149
2 changed files with 4 additions and 3 deletions

View File

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

View File

@ -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;
};
}