mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-25 03:00:49 +00:00
do not run trace collector without trace_log. do not run query profilers without trace collector.
This commit is contained in:
parent
17e3542a5a
commit
ef1d84b35a
@ -292,7 +292,7 @@ struct ContextShared
|
||||
ddl_worker.reset();
|
||||
|
||||
/// Trace collector is only initialized in server program
|
||||
if (trace_collector != nullptr)
|
||||
if (hasTraceCollector())
|
||||
{
|
||||
/// Stop trace collector
|
||||
NotifyTraceCollectorToStop();
|
||||
@ -304,8 +304,15 @@ struct ContextShared
|
||||
}
|
||||
}
|
||||
|
||||
bool hasTraceCollector() {
|
||||
return trace_collector != nullptr;
|
||||
}
|
||||
|
||||
void initializeTraceCollector(std::shared_ptr<TraceLog> trace_log)
|
||||
{
|
||||
if (trace_log == nullptr)
|
||||
return;
|
||||
|
||||
trace_pipe.open();
|
||||
trace_collector.reset(new TraceCollector(trace_log));
|
||||
trace_collector_thread.start(*trace_collector);
|
||||
@ -1646,6 +1653,11 @@ void Context::initializeSystemLogs()
|
||||
shared->system_logs.emplace(*global_context, getConfigRef());
|
||||
}
|
||||
|
||||
bool Context::hasTraceCollector()
|
||||
{
|
||||
return shared->hasTraceCollector();
|
||||
}
|
||||
|
||||
void Context::initializeTraceCollector()
|
||||
{
|
||||
shared->initializeTraceCollector(getTraceLog());
|
||||
|
@ -416,6 +416,7 @@ public:
|
||||
void initializeSystemLogs();
|
||||
|
||||
void initializeTraceCollector();
|
||||
bool hasTraceCollector();
|
||||
|
||||
/// Nullptr if the query log is not ready for this moment.
|
||||
std::shared_ptr<QueryLog> getQueryLog();
|
||||
|
@ -126,8 +126,9 @@ void ThreadStatus::finalizePerformanceCounters()
|
||||
|
||||
void ThreadStatus::initQueryProfiler()
|
||||
{
|
||||
if (!query_context)
|
||||
throw Exception("Can't init query profiler without query context", ErrorCodes::LOGICAL_ERROR);
|
||||
/// query profilers are useless without trace collector
|
||||
if (!global_context->hasTraceCollector())
|
||||
return;
|
||||
|
||||
auto & settings = query_context->getSettingsRef();
|
||||
|
||||
@ -146,8 +147,8 @@ void ThreadStatus::initQueryProfiler()
|
||||
|
||||
void ThreadStatus::finalizeQueryProfiler()
|
||||
{
|
||||
query_profiler_real.reset(nullptr);
|
||||
query_profiler_cpu.reset(nullptr);
|
||||
query_profiler_real.reset();
|
||||
query_profiler_cpu.reset();
|
||||
}
|
||||
|
||||
void ThreadStatus::detachQuery(bool exit_if_already_detached, bool thread_exits)
|
||||
|
Loading…
Reference in New Issue
Block a user