@@ -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;
0 commit comments