github-actions[bot] commented on code in PR #30973:
URL: https://github.com/apache/doris/pull/30973#discussion_r1481501838


##########
be/src/olap/wal/wal_manager.cpp:
##########
@@ -232,9 +233,68 @@
     return Status::OK();
 }
 
-Status WalManager::_scan_wals(const std::string& wal_path) {
-    size_t count = 0;
-    bool exists = true;
+Status WalManager::parse_wal_path(const std::string& file_name, int64_t& 
version,
+                                  int64_t& backend_id, int64_t& wal_id, 
std::string& label) {
+    try {
+        // find version
+        auto pos = file_name.find("_");
+        version = std::strtoll(file_name.substr(0, pos).c_str(), NULL, 10);
+        // find be id
+        auto substring1 = file_name.substr(pos + 1);
+        pos = substring1.find("_");
+        backend_id = std::strtoll(substring1.substr(0, pos).c_str(), NULL, 10);
+        // find wal id
+        auto substring2 = substring1.substr(pos + 1);
+        pos = substring2.find("_");
+        wal_id = std::strtoll(substring2.substr(0, pos).c_str(), NULL, 10);
+        // find label
+        label = substring2.substr(pos + 1);
+        VLOG_DEBUG << "version:" << version << "backend_id:" << backend_id << 
",wal_id:" << wal_id
+                   << ",label:" << label;
+    } catch (const std::invalid_argument& e) {
+        return Status::InvalidArgument("Invalid format, {}", e.what());
+    }
+    return Status::OK();
+}
+
+Status WalManager::_replay_wal() {
+    std::vector<ScanWalInfo> wals;
+    for (auto wal_dir : _wal_dirs) {
+        RETURN_IF_ERROR(_scan_wals(wal_dir, wals));
+    }
+    for (const auto& wal : wals) {
+        bool exists = false;
+        RETURN_IF_ERROR(io::global_local_filesystem()->exists(wal.wal_path, 
&exists));
+        if (!exists) {
+            continue;
+        }
+        LOG(INFO) << "find wal: " << wal.wal_path;
+        {
+            std::lock_guard<std::shared_mutex> wrlock(_wal_path_lock);
+            auto it = _wal_path_map.find(wal.wal_id);
+            if (it != _wal_path_map.end()) {
+                LOG(INFO) << "wal_id " << wal.wal_id << " already in 
wal_path_map, skip it";
+                continue;
+            }
+            _wal_path_map.emplace(wal.wal_id, wal.wal_path);
+        }
+        // this config is use for test p0 case in pipeline
+        if (config::group_commit_wait_replay_wal_finish) {
+            auto lock = std::make_shared<std::mutex>();
+            auto cv = std::make_shared<std::condition_variable>();
+            auto add_st = add_wal_cv_map(wal.wal_id, lock, cv);
+            if (!add_st.ok()) {
+                LOG(WARNING) << "fail to add wal_id " << wal.wal_id << " to 
wal_cv_map";
+                continue;
+            }
+        }
+        RETURN_IF_ERROR(add_recover_wal(wal.db_id, wal.tb_id, wal.wal_id, 
wal.wal_path));
+    }
+    return Status::OK();
+}
+
+Status WalManager::_scan_wals(const std::string& wal_path, 
std::vector<ScanWalInfo>& res) {

Review Comment:
   warning: method '_scan_wals' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static Status WalManager::_scan_wals(const std::string& wal_path, 
std::vector<ScanWalInfo>& res) {
   ```
   



##########
be/src/olap/wal/wal_manager.cpp:
##########
@@ -232,9 +233,68 @@
     return Status::OK();
 }
 
-Status WalManager::_scan_wals(const std::string& wal_path) {
-    size_t count = 0;
-    bool exists = true;
+Status WalManager::parse_wal_path(const std::string& file_name, int64_t& 
version,
+                                  int64_t& backend_id, int64_t& wal_id, 
std::string& label) {
+    try {
+        // find version
+        auto pos = file_name.find("_");
+        version = std::strtoll(file_name.substr(0, pos).c_str(), NULL, 10);
+        // find be id
+        auto substring1 = file_name.substr(pos + 1);
+        pos = substring1.find("_");
+        backend_id = std::strtoll(substring1.substr(0, pos).c_str(), NULL, 10);
+        // find wal id
+        auto substring2 = substring1.substr(pos + 1);
+        pos = substring2.find("_");
+        wal_id = std::strtoll(substring2.substr(0, pos).c_str(), NULL, 10);
+        // find label
+        label = substring2.substr(pos + 1);
+        VLOG_DEBUG << "version:" << version << "backend_id:" << backend_id << 
",wal_id:" << wal_id
+                   << ",label:" << label;
+    } catch (const std::invalid_argument& e) {
+        return Status::InvalidArgument("Invalid format, {}", e.what());
+    }
+    return Status::OK();
+}
+
+Status WalManager::_replay_wal() {

Review Comment:
   warning: method '_replay_wal' can be made static 
[readability-convert-member-functions-to-static]
   
   be/src/olap/wal/wal_manager.h:114:
   ```diff
   -     Status _replay_wal();
   +     static Status _replay_wal();
   ```
   



##########
be/src/olap/wal/wal_manager.cpp:
##########
@@ -232,9 +233,68 @@ Status WalManager::get_wal_path(int64_t wal_id, 
std::string& wal_path) {
     return Status::OK();
 }
 
-Status WalManager::_scan_wals(const std::string& wal_path) {
-    size_t count = 0;
-    bool exists = true;
+Status WalManager::parse_wal_path(const std::string& file_name, int64_t& 
version,

Review Comment:
   warning: method 'parse_wal_path' can be made static 
[readability-convert-member-functions-to-static]
   
   ```suggestion
   static Status WalManager::parse_wal_path(const std::string& file_name, 
int64_t& version,
   ```
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


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

Reply via email to