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


##########
be/src/olap/wal_manager.cpp:
##########
@@ -75,11 +78,42 @@ Status WalManager::init() {
         }
         RETURN_IF_ERROR(scan_wals(wal_dir));
     }
+    RETURN_IF_ERROR(init_wal_limit());
     return Thread::create(
             "WalMgr", "replay_wal", [this]() { 
static_cast<void>(this->replay()); },
             &_replay_thread);
 }
 
+Status WalManager::init_wal_limit() {
+    size_t available_bytes;
+    size_t disk_capacity_bytes;
+    // Get the root path available space.
+    RETURN_IF_ERROR(io::global_local_filesystem()->get_space_info("./", 
&disk_capacity_bytes,
+                                                                  
&available_bytes));
+    bool is_percent = true;
+    int64_t wal_disk_limit =
+            ParseUtil::parse_mem_spec(config::wal_max_disk_limit, -1, 
available_bytes, &is_percent);
+    if (wal_disk_limit < 0 || wal_disk_limit > available_bytes) {
+        return Status::InternalError(
+                "wal_max_disk_limit config is wrong, please check your 
config!");
+    }
+    WalManager::wal_limit = wal_disk_limit;
+    return Status::OK();
+}
+
+// Just used for ut.
+Status WalManager::init_wal_limit(size_t available_bytes) {

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



##########
be/test/olap/wal_manager_test.cpp:
##########
@@ -123,4 +124,91 @@ TEST_F(WalManagerTest, recovery_normal) {
     ASSERT_TRUE(!std::filesystem::exists(wal_200));
     ASSERT_TRUE(!std::filesystem::exists(wal_201));
 }
+
+TEST_F(WalManagerTest, TestDynamicWalSpaceLimt) {

Review Comment:
   warning: function 'TEST_F' exceeds recommended size/complexity thresholds 
[readability-function-size]
   ```cpp
   TEST_F(WalManagerTest, TestDynamicWalSpaceLimt) {
   ^
   ```
   <details>
   <summary>Additional context</summary>
   
   **be/test/olap/wal_manager_test.cpp:127:** 85 lines including whitespace and 
comments (threshold 80)
   ```cpp
   TEST_F(WalManagerTest, TestDynamicWalSpaceLimt) {
   ^
   ```
   
   </details>
   



-- 
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