From cfb8809283477766ce737c71283204474b5ed877 Mon Sep 17 00:00:00 2001 From: zhannngchen <48427519+zhannngchen@users.noreply.github.com> Date: Wed, 3 Jul 2024 22:48:26 +0800 Subject: [PATCH] [enhancement](trash) support skip trash, update trash default expire time (#37170) ## Proposed changes Issue Number: close #xxx 1. if user set `trash_file_expire_time_sec` to 0, skip trash directly 2. update trash_file_expire_time_sec default value from 3 days to 1 day docs PR: https://github.com/apache/doris-website/pull/817 --- be/src/common/config.cpp | 2 +- be/src/olap/data_dir.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index cbae3ee896beaa..11e2635047b291 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -312,7 +312,7 @@ DEFINE_mInt32(garbage_sweep_batch_size, "100"); DEFINE_mInt32(snapshot_expire_time_sec, "172800"); // It is only a recommended value. When the disk space is insufficient, // the file storage period under trash dose not have to comply with this parameter. -DEFINE_mInt32(trash_file_expire_time_sec, "259200"); +DEFINE_mInt32(trash_file_expire_time_sec, "86400"); // minimum file descriptor number // modify them upon necessity DEFINE_Int32(min_file_descriptor_number, "60000"); diff --git a/be/src/olap/data_dir.cpp b/be/src/olap/data_dir.cpp index 37dd76c848c4a4..98bc721c048fbe 100644 --- a/be/src/olap/data_dir.cpp +++ b/be/src/olap/data_dir.cpp @@ -927,8 +927,14 @@ void DataDir::disks_compaction_num_increment(int64_t delta) { } Status DataDir::move_to_trash(const std::string& tablet_path) { - Status res = Status::OK(); + if (config::trash_file_expire_time_sec <= 0) { + LOG(INFO) << "delete tablet dir " << tablet_path + << " directly due to trash_file_expire_time_sec is 0"; + RETURN_IF_ERROR(io::global_local_filesystem()->delete_directory(tablet_path)); + return delete_tablet_parent_path_if_empty(tablet_path); + } + Status res = Status::OK(); // 1. get timestamp string string time_str; if ((res = gen_timestamp_string(&time_str)) != Status::OK()) {