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

jianliangqi 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 4a57f644d08 [fix](inverted index)Delete tmp dirs when BE starts to 
avoid tmp file… (#35951)
4a57f644d08 is described below

commit 4a57f644d08b165f562307dd320b66cecf943881
Author: qiye <jianliang5...@gmail.com>
AuthorDate: Fri Jun 7 10:46:35 2024 +0800

    [fix](inverted index)Delete tmp dirs when BE starts to avoid tmp file… 
(#35951)
    
    …s left by last crash
    
    When BE crashes, there may be tmp files left in the tmp dir, so we
    remove and rebuild the tmp dir every time we start BE to prevent rubbish
    data from occupying the disk.
    
    Co-authored-by: Luennng <luen...@gmail.com>
---
 be/src/olap/compaction.cpp                            | 3 +--
 be/src/olap/rowset/segment_v2/inverted_index_writer.h | 8 +++-----
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/be/src/olap/compaction.cpp b/be/src/olap/compaction.cpp
index 3f1579ff276..47be4e01e07 100644
--- a/be/src/olap/compaction.cpp
+++ b/be/src/olap/compaction.cpp
@@ -663,8 +663,7 @@ Status Compaction::do_inverted_index_compaction() {
         }
     }
 
-    // we choose the first destination segment name as the temporary index 
writer path
-    // Used to distinguish between different index compaction
+    // use tmp file dir to store index files
     auto tmp_file_dir = 
ExecEnv::GetInstance()->get_tmp_file_dirs()->get_tmp_file_dir();
     auto index_tmp_path = tmp_file_dir / dest_rowset_id.to_string();
     LOG(INFO) << "start index compaction"
diff --git a/be/src/olap/rowset/segment_v2/inverted_index_writer.h 
b/be/src/olap/rowset/segment_v2/inverted_index_writer.h
index 77873905af1..06bc960bc33 100644
--- a/be/src/olap/rowset/segment_v2/inverted_index_writer.h
+++ b/be/src/olap/rowset/segment_v2/inverted_index_writer.h
@@ -106,11 +106,9 @@ public:
 
     Status init() {
         for (auto& tmp_file_dir : _tmp_file_dirs) {
-            bool exists = true;
-            
RETURN_IF_ERROR(io::global_local_filesystem()->exists(tmp_file_dir, &exists));
-            if (!exists) {
-                
RETURN_IF_ERROR(io::global_local_filesystem()->create_directory(tmp_file_dir));
-            }
+            // delete the tmp dir to avoid the tmp files left by last crash
+            
RETURN_IF_ERROR(io::global_local_filesystem()->delete_directory(tmp_file_dir));
+            
RETURN_IF_ERROR(io::global_local_filesystem()->create_directory(tmp_file_dir));
         }
         return Status::OK();
     };


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

Reply via email to