From e7c966c6043dcd8d5a1b3b61c7048b821c362b2c Mon Sep 17 00:00:00 2001 From: Xinyi Zou Date: Wed, 19 Feb 2025 12:04:47 +0800 Subject: [PATCH] [fix](resource) Fix register ResourceContext to RuntimeQueryStatisticsMgr (#48004) ### What problem does this PR solve? Wait for QueryTaskController to be initialized before register ResourceContext fix ``` /root/doris/be/src/runtime/workload_management/task_controller.h:59:44: runtime error: load of value 3200171710, which is not a valid value for type 'TQueryType::type' #0 0x555ff9336162 in doris::TaskController::query_type() /root/doris/be/src/runtime/workload_management/task_controller.h:59:44 #1 0x555ff9336162 in doris::RuntimeQueryStatisticsMgr::report_runtime_query_statistics() /root/doris/be/src/runtime/runtime_query_statistics_mgr.cpp:346:50 #2 0x555ff50d789d in doris::Daemon::report_runtime_query_statistics_thread() /root/doris/be/src/common/daemon.cpp:487:65 #3 0x555ff9a3efae in std::function::operator()() const /var/local/ldb-toolchain/bin/../lib/gcc/x86_64-linux-gnu/11/../../../../include/c++/11/bits/std_function.h:560:9 #4 0x555ff9a3efae in doris::Thread::supervise_thread(void*) /root/doris/be/src/util/thread.cpp:498:5 #5 0x7f4935d00608 in start_thread /build/glibc-SzIz7B/glibc-2.31/nptl/pthread_create.c:477:8 #6 0x7f4935fad132 in __clone /build/glibc-SzIz7B/glibc-2.31/misc/../sysdeps/unix/sysv/linux/x86_64/clone.S:95 ``` --- be/src/runtime/query_context.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/be/src/runtime/query_context.cpp b/be/src/runtime/query_context.cpp index 9334db576ffb52..4f10aa80535b86 100644 --- a/be/src/runtime/query_context.cpp +++ b/be/src/runtime/query_context.cpp @@ -181,10 +181,6 @@ void QueryContext::_init_resource_context() { _resource_ctx = ResourceContext::create_shared(); _resource_ctx->set_memory_context(QueryContext::QueryMemoryContext::create()); _init_query_mem_tracker(); -#ifndef BE_TEST - _exec_env->runtime_query_statistics_mgr()->register_resource_context(print_id(_query_id), - _resource_ctx); -#endif } void QueryContext::init_query_task_controller() { @@ -192,6 +188,10 @@ void QueryContext::init_query_task_controller() { _resource_ctx->task_controller()->set_task_id(_query_id); _resource_ctx->task_controller()->set_fe_addr(current_connect_fe); _resource_ctx->task_controller()->set_query_type(_query_options.query_type); +#ifndef BE_TEST + _exec_env->runtime_query_statistics_mgr()->register_resource_context(print_id(_query_id), + _resource_ctx); +#endif } QueryContext::~QueryContext() {