@@ -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 ;
@@ -809,30 +810,12 @@ void PackedFileManager::cleanup_expired_data() {
809810
810811 // Clean up expired global index entries
811812 {
812- std::unordered_set<std::string> active_packed_files;
813- {
814- std::lock_guard<std::timed_mutex> current_lock (_current_packed_file_mutex);
815- for (const auto & [resource_id, state] : _current_packed_files) {
816- if (state) {
817- active_packed_files.insert (state->packed_file_path );
818- }
819- }
820- }
821- {
822- std::lock_guard<std::mutex> merge_lock (_packed_files_mutex);
823- for (const auto & [path, state] : _uploading_packed_files) {
824- active_packed_files.insert (path);
825- }
826- for (const auto & [path, state] : _uploaded_packed_files) {
827- active_packed_files.insert (path);
828- }
829- }
830-
831813 std::lock_guard<std::mutex> global_lock (_global_index_mutex);
832814 auto it = _global_slice_locations.begin ();
833815 while (it != _global_slice_locations.end ()) {
834816 const auto & index = it->second ;
835- if (active_packed_files.find (index.packed_file_path ) == active_packed_files.end ()) {
817+ if (index.create_time > 0 &&
818+ current_time - index.create_time > config::uploaded_file_retention_seconds) {
836819 it = _global_slice_locations.erase (it);
837820 } else {
838821 ++it;
0 commit comments