This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/master by this push:
     new c346f4d6386 [Improvement](Storage) Lazy init mini_download dir (#24649)
c346f4d6386 is described below

commit c346f4d6386f35b261e7063e90bc3a329b664ee8
Author: HHoflittlefish777 <77738092+hhoflittlefish...@users.noreply.github.com>
AuthorDate: Fri Sep 22 16:23:26 2023 +0800

    [Improvement](Storage) Lazy init mini_download dir (#24649)
---
 be/src/runtime/load_path_mgr.cpp | 13 ++++++-------
 be/src/runtime/load_path_mgr.h   |  2 ++
 2 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/be/src/runtime/load_path_mgr.cpp b/be/src/runtime/load_path_mgr.cpp
index e241eeafea4..93fbeb7d929 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 de443f059b4..6c81b940a23 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 @@ private:
     uint32_t _error_path_next_shard;
     CountDownLatch _stop_background_threads_latch;
     scoped_refptr<Thread> _clean_thread;
+    DorisCallOnce<Status> _init_once;
 };
 
 } // namespace doris


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org
For additional commands, e-mail: commits-h...@doris.apache.org

Reply via email to