mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-29 19:12:03 +00:00
PushingToViewsBlockOutputStream: Detatch ThreadStatus'
This commit is contained in:
parent
75d18bc79b
commit
e4b65da6e4
@ -144,14 +144,14 @@ PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream(
|
||||
if (!running_memory_tracker)
|
||||
running_memory_tracker = &total_memory_tracker;
|
||||
|
||||
auto thread_status = std::make_shared<ThreadStatus>();
|
||||
auto thread_status = std::make_unique<ThreadStatus>();
|
||||
thread_status->attachQueryContext(getContext());
|
||||
thread_status->memory_tracker.setParent(running_memory_tracker);
|
||||
|
||||
QueryViewsLogElement::ViewRuntimeStats runtime_stats{
|
||||
target_name,
|
||||
type,
|
||||
thread_status,
|
||||
std::move(thread_status),
|
||||
0,
|
||||
std::chrono::system_clock::now(),
|
||||
QueryViewsLogElement::ViewStatus::EXCEPTION_BEFORE_START};
|
||||
@ -178,6 +178,23 @@ PushingToViewsBlockOutputStream::PushingToViewsBlockOutputStream(
|
||||
}
|
||||
}
|
||||
|
||||
PushingToViewsBlockOutputStream::~PushingToViewsBlockOutputStream()
|
||||
{
|
||||
for (auto & view : views)
|
||||
{
|
||||
if (view.runtime_stats.thread_status)
|
||||
{
|
||||
try
|
||||
{
|
||||
view.runtime_stats.thread_status->detachQuery(true, true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
tryLogCurrentException(__PRETTY_FUNCTION__);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Block PushingToViewsBlockOutputStream::getHeader() const
|
||||
{
|
||||
|
@ -43,6 +43,8 @@ public:
|
||||
const ASTPtr & query_ptr_,
|
||||
bool no_destination = false);
|
||||
|
||||
~PushingToViewsBlockOutputStream() override;
|
||||
|
||||
Block getHeader() const override;
|
||||
void write(const Block & block) override;
|
||||
|
||||
|
@ -36,7 +36,7 @@ struct QueryViewsLogElement
|
||||
{
|
||||
String target_name;
|
||||
ViewType type = ViewType::DEFAULT;
|
||||
std::shared_ptr<ThreadStatus> thread_status = nullptr;
|
||||
std::unique_ptr<ThreadStatus> thread_status = nullptr;
|
||||
UInt64 elapsed_ms = 0;
|
||||
std::chrono::time_point<std::chrono::system_clock> event_time;
|
||||
ViewStatus event_status = ViewStatus::QUERY_START;
|
||||
|
Loading…
Reference in New Issue
Block a user