From e7a7fcfc5c7d6ac6f402a3462e2b33d3149c9b6f Mon Sep 17 00:00:00 2001 From: yiguolei Date: Fri, 27 Dec 2024 16:34:37 +0800 Subject: [PATCH] f --- be/src/runtime/exec_env_init.cpp | 9 +++++---- be/src/service/doris_main.cpp | 6 ++++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/be/src/runtime/exec_env_init.cpp b/be/src/runtime/exec_env_init.cpp index 5a45f133f14babf..4c3c6165857e57b 100644 --- a/be/src/runtime/exec_env_init.cpp +++ b/be/src/runtime/exec_env_init.cpp @@ -185,10 +185,14 @@ ThreadPool* ExecEnv::non_block_close_thread_pool() { #endif } -ExecEnv::ExecEnv() = default; +ExecEnv::ExecEnv() { + // Doris Metrics is firstly initialized. + _doris_metrics = std::make_unique(); +} ExecEnv::~ExecEnv() { destroy(); + _doris_metrics.reset(); } Status ExecEnv::init(ExecEnv* env, const std::vector& store_paths, @@ -204,8 +208,6 @@ Status ExecEnv::_init(const std::vector& store_paths, if (ready()) { return Status::OK(); } - // Doris Metrics is firstly initialized. - _doris_metrics = std::make_unique(); std::unordered_map> spill_store_map; for (const auto& spill_path : spill_store_paths) { @@ -845,7 +847,6 @@ void ExecEnv::destroy() { SAFE_DELETE(_heap_profiler); _s_tracking_memory = false; - _doris_metrics.reset(); LOG(INFO) << "Doris exec envorinment is destoried."; } diff --git a/be/src/service/doris_main.cpp b/be/src/service/doris_main.cpp index 00935e8fc64bedd..e1485ca90e042b3 100644 --- a/be/src/service/doris_main.cpp +++ b/be/src/service/doris_main.cpp @@ -425,6 +425,10 @@ int main(int argc, char** argv) { << doris::config::spill_storage_root_path; exit(-1); } + + // Should create exec env instance before others because many other modules depend on doris metrics in it. + auto* exec_env(doris::ExecEnv::GetInstance()); + std::set broken_paths; doris::parse_conf_broken_store_paths(doris::config::broken_storage_path, &broken_paths); @@ -525,8 +529,6 @@ int main(int argc, char** argv) { doris::ThreadLocalHandle::create_thread_local_if_not_exits(); - // init exec env - auto* exec_env(doris::ExecEnv::GetInstance()); status = doris::ExecEnv::init(doris::ExecEnv::GetInstance(), paths, spill_paths, broken_paths); if (status != Status::OK()) { std::cerr << "failed to init doris storage engine, res=" << status;