gavinchou commented on code in PR #30893:
URL: https://github.com/apache/doris/pull/30893#discussion_r1480188858


##########
be/src/vec/sink/group_commit_block_sink.cpp:
##########
@@ -292,5 +298,26 @@ size_t GroupCommitBlockSink::_pre_allocated(bool 
is_blocks_contain_all_load_data
                                                              : 
_state->content_length());
 }
 
+void GroupCommitBlockSink::_remove_pre_allocated() {
+    if (!_is_pre_allocated_removed) {
+        std::string wal_path;
+        Status st = 
ExecEnv::GetInstance()->wal_mgr()->get_wal_path(_load_block_queue->txn_id,
+                                                                    wal_path);
+        if (!st.ok()) {
+            LOG(WARNING) << "Failed to get wal path in remove pre allocated, 
reason: "
+                         << st.to_string();
+            return;
+        }
+        st = ExecEnv::GetInstance()->wal_mgr()->update_wal_dir_pre_allocated(
+                WalManager::get_base_wal_path(wal_path), 0, _pre_allocated);
+        if (!st.ok()) {
+            LOG(WARNING) << "Failed to remove pre allocated, reason: " << 
st.to_string();
+            return;
+        }
+        _is_pre_allocated_removed = true;
+        _load_block_queue->block_queue_pre_allocated.fetch_sub(_pre_allocated);
+    }
+};

Review Comment:
   Check to return to reduce indention.
   ```suggestion
       if (_is_pre_allocated_removed) return;
       
       std::string wal_path;
       Status st = 
ExecEnv::GetInstance()->wal_mgr()->get_wal_path(_load_block_queue->txn_id,
                                                                   wal_path);
       if (!st.ok()) {
           LOG(WARNING) << "Failed to get wal path in remove pre allocated, 
reason: "
                        << st.to_string();
           return;
       }
       st = ExecEnv::GetInstance()->wal_mgr()->update_wal_dir_pre_allocated(
               WalManager::get_base_wal_path(wal_path), 0, _pre_allocated);
       if (!st.ok()) {
           LOG(WARNING) << "Failed to remove pre allocated, reason: " << 
st.to_string();
           return;
       }
       _is_pre_allocated_removed = true;
       _load_block_queue->block_queue_pre_allocated.fetch_sub(_pre_allocated);
   }
   ```



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