From cc7ab2b9fe04877fdc6a5fa859ea6ce521e1a2d4 Mon Sep 17 00:00:00 2001 From: qiye Date: Wed, 12 Jun 2024 23:05:44 +0800 Subject: [PATCH] [fix](inverted index)Delete tmp dirs when BE starts to avoid tmp files left by last crash #35951 (#36190) 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. --- be/src/olap/rowset/segment_v2/inverted_index_writer.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) 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 77873905af..06bc960bc3 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(); };