mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 08:32:02 +00:00
Separate thread mutex, add test
This commit is contained in:
parent
d601d86fad
commit
aa888ad64a
@ -214,7 +214,7 @@ SystemLogBase<LogElement>::SystemLogBase(
|
||||
template <typename LogElement>
|
||||
void SystemLogBase<LogElement>::startup()
|
||||
{
|
||||
std::lock_guard lock(queue->mutex);
|
||||
std::lock_guard lock(thread_mutex);
|
||||
saving_thread = std::make_unique<ThreadFromGlobalPool>([this] { savingThreadFunction(); });
|
||||
}
|
||||
|
||||
|
@ -67,6 +67,7 @@ public:
|
||||
virtual void savingThreadFunction() = 0;
|
||||
|
||||
protected:
|
||||
std::mutex thread_mutex;
|
||||
std::unique_ptr<ThreadFromGlobalPool> saving_thread;
|
||||
|
||||
bool is_shutdown = false;
|
||||
@ -93,10 +94,10 @@ public:
|
||||
Index pop(std::vector<LogElement>& output, bool& should_prepare_tables_anyway, bool& exit_this_thread);
|
||||
void confirm(Index to_flush_end);
|
||||
|
||||
private:
|
||||
/// Data shared between callers of add()/flush()/shutdown(), and the saving thread
|
||||
std::mutex mutex;
|
||||
|
||||
private:
|
||||
Poco::Logger * log;
|
||||
|
||||
// Queue is bounded. But its size is quite large to not block in all normal cases.
|
||||
|
@ -358,7 +358,7 @@ template <typename LogElement>
|
||||
void SystemLog<LogElement>::stopFlushThread()
|
||||
{
|
||||
{
|
||||
std::lock_guard lock(queue->mutex);
|
||||
std::lock_guard lock(thread_mutex);
|
||||
|
||||
if (!saving_thread || !saving_thread->joinable())
|
||||
return;
|
||||
|
@ -124,6 +124,7 @@ protected:
|
||||
|
||||
using ISystemLog::is_shutdown;
|
||||
using ISystemLog::saving_thread;
|
||||
using ISystemLog::thread_mutex;
|
||||
using Base::queue;
|
||||
|
||||
private:
|
||||
|
@ -0,0 +1 @@
|
||||
1
|
2
tests/queries/0_stateless/02813_starting_in_text_log.sql
Executable file
2
tests/queries/0_stateless/02813_starting_in_text_log.sql
Executable file
@ -0,0 +1,2 @@
|
||||
SYSTEM FLUSH LOGS;
|
||||
SELECT count() > 0 FROM system.text_log WHERE event_date >= yesterday() AND message LIKE '%Application: Starting ClickHouse%';
|
Loading…
Reference in New Issue
Block a user