Skip to content

Commit

Permalink
[fix](inverted index)Delete tmp dirs when BE starts to avoid tmp file… (
Browse files Browse the repository at this point in the history
#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 <[email protected]>
  • Loading branch information
qidaye and luennng authored Jun 7, 2024
1 parent ee45ed2 commit 4a57f64
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 7 deletions.
3 changes: 1 addition & 2 deletions be/src/olap/compaction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
8 changes: 3 additions & 5 deletions be/src/olap/rowset/segment_v2/inverted_index_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,9 @@ class TmpFileDirs {

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();
};
Expand Down

0 comments on commit 4a57f64

Please sign in to comment.