diff --git a/be/src/runtime/load_path_mgr.cpp b/be/src/runtime/load_path_mgr.cpp index e241eeafea4ce2..93fbeb7d929425 100644 --- a/be/src/runtime/load_path_mgr.cpp +++ b/be/src/runtime/load_path_mgr.cpp @@ -65,9 +65,6 @@ void LoadPathMgr::stop() { Status LoadPathMgr::init() { _path_vec.clear(); - for (auto& path : _exec_env->store_paths()) { - _path_vec.push_back(path.path + "/" + MINI_PREFIX); - } LOG(INFO) << "Load path configured to [" << boost::join(_path_vec, ",") << "]"; // error log is saved in first root path @@ -91,13 +88,15 @@ Status LoadPathMgr::init() { Status LoadPathMgr::allocate_dir(const std::string& db, const std::string& label, std::string* prefix) { - if (_path_vec.empty()) { - return Status::InternalError("No load path configured."); - } + Status status = _init_once.call([this] { + for (auto& store_path : _exec_env->store_paths()) { + _path_vec.push_back(store_path.path + "/" + MINI_PREFIX); + } + return Status::OK(); + }); std::string path; auto size = _path_vec.size(); auto retry = size; - Status status = Status::OK(); while (retry--) { { // add SHARD_PREFIX for compatible purpose diff --git a/be/src/runtime/load_path_mgr.h b/be/src/runtime/load_path_mgr.h index de443f059b4867..6c81b940a2374a 100644 --- a/be/src/runtime/load_path_mgr.h +++ b/be/src/runtime/load_path_mgr.h @@ -27,6 +27,7 @@ #include "common/status.h" #include "gutil/ref_counted.h" #include "util/countdown_latch.h" +#include "util/once.h" namespace doris { @@ -70,6 +71,7 @@ class LoadPathMgr { uint32_t _error_path_next_shard; CountDownLatch _stop_background_threads_latch; scoped_refptr _clean_thread; + DorisCallOnce _init_once; }; } // namespace doris