Skip to content

Commit 6ec35ec

Browse files
authored
[fix](packed-file) use timestamp-only cleanup for packed slice index (#59369)
1 parent 38e7ffd commit 6ec35ec

File tree

2 files changed

+4
-20
lines changed

2 files changed

+4
-20
lines changed

be/src/io/fs/packed_file_manager.cpp

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,7 @@ Status PackedFileManager::append_small_file(const std::string& path, const Slice
256256
location.packed_file_path = active_state->packed_file_path;
257257
location.offset = active_state->current_offset;
258258
location.size = data.get_size();
259+
location.create_time = std::time(nullptr);
259260
location.tablet_id = info.tablet_id;
260261
location.rowset_id = info.rowset_id;
261262
location.resource_id = info.resource_id;
@@ -818,30 +819,12 @@ void PackedFileManager::cleanup_expired_data() {
818819

819820
// Clean up expired global index entries
820821
{
821-
std::unordered_set<std::string> active_packed_files;
822-
{
823-
std::lock_guard<std::timed_mutex> current_lock(_current_packed_file_mutex);
824-
for (const auto& [resource_id, state] : _current_packed_files) {
825-
if (state) {
826-
active_packed_files.insert(state->packed_file_path);
827-
}
828-
}
829-
}
830-
{
831-
std::lock_guard<std::mutex> merge_lock(_packed_files_mutex);
832-
for (const auto& [path, state] : _uploading_packed_files) {
833-
active_packed_files.insert(path);
834-
}
835-
for (const auto& [path, state] : _uploaded_packed_files) {
836-
active_packed_files.insert(path);
837-
}
838-
}
839-
840822
std::lock_guard<std::mutex> global_lock(_global_index_mutex);
841823
auto it = _global_slice_locations.begin();
842824
while (it != _global_slice_locations.end()) {
843825
const auto& index = it->second;
844-
if (active_packed_files.find(index.packed_file_path) == active_packed_files.end()) {
826+
if (index.create_time > 0 &&
827+
current_time - index.create_time > config::uploaded_file_retention_seconds) {
845828
it = _global_slice_locations.erase(it);
846829
} else {
847830
++it;

be/src/io/fs/packed_file_manager.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ struct PackedSliceLocation {
4545
std::string packed_file_path;
4646
int64_t offset;
4747
int64_t size;
48+
int64_t create_time = 0;
4849
int64_t tablet_id = 0;
4950
std::string rowset_id;
5051
std::string resource_id;

0 commit comments

Comments
 (0)