From 91aebce4e87a6c9f739c55969d9e9eae9e29fe03 Mon Sep 17 00:00:00 2001 From: Yixuan Wang Date: Mon, 13 Jul 2026 16:38:57 +0800 Subject: [PATCH] 1 --- cloud/src/recycler/recycler.cpp | 41 ++++++++++++++++++++++++++------- cloud/test/recycler_test.cpp | 6 ++++- 2 files changed, 38 insertions(+), 9 deletions(-) diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp index 614c2084857a84..bfe2832006fdfb 100644 --- a/cloud/src/recycler/recycler.cpp +++ b/cloud/src/recycler/recycler.cpp @@ -106,6 +106,21 @@ bool filter_out_instance(const std::string& instance_id) { config::recycle_whitelist.end(); } +bool is_packed_slice_path(const doris::RowsetMetaCloudPB& rowset, const std::string& path) { + const auto& locations = rowset.packed_slice_locations(); + auto it = locations.find(path); + return it != locations.end() && it->second.has_packed_file_path() && + !it->second.packed_file_path().empty(); +} + +void add_file_to_delete_if_not_packed(const doris::RowsetMetaCloudPB& rowset, + const std::string& path, + std::vector* file_paths) { + if (!is_packed_slice_path(rowset, path)) { + file_paths->push_back(path); + } +} + } // namespace // return 0 for success get a key, 1 for key not found, negative for error @@ -3150,14 +3165,19 @@ int InstanceRecycler::delete_rowset_data(const RowsetMetaCloudPB& rs_meta_pb) { int64_t tablet_id = rs_meta_pb.tablet_id(); const auto& rowset_id = rs_meta_pb.rowset_id_v2(); for (int64_t i = 0; i < num_segments; ++i) { - file_paths.push_back(segment_path(tablet_id, rowset_id, i)); + add_file_to_delete_if_not_packed(rs_meta_pb, segment_path(tablet_id, rowset_id, i), + &file_paths); if (index_format == InvertedIndexStorageFormatPB::V1) { for (const auto& index_id : index_ids) { - file_paths.push_back(inverted_index_path_v1(tablet_id, rowset_id, i, index_id.first, - index_id.second)); + add_file_to_delete_if_not_packed( + rs_meta_pb, + inverted_index_path_v1(tablet_id, rowset_id, i, index_id.first, + index_id.second), + &file_paths); } } else if (!index_ids.empty()) { - file_paths.push_back(inverted_index_path_v2(tablet_id, rowset_id, i)); + add_file_to_delete_if_not_packed( + rs_meta_pb, inverted_index_path_v2(tablet_id, rowset_id, i), &file_paths); } } @@ -3901,11 +3921,15 @@ int InstanceRecycler::delete_rowset_data( continue; } for (int64_t i = 0; i < num_segments; ++i) { - file_paths.push_back(segment_path(tablet_id, rowset_id, i)); + add_file_to_delete_if_not_packed(rs, segment_path(tablet_id, rowset_id, i), + &file_paths); if (index_format == InvertedIndexStorageFormatPB::V1) { for (const auto& index_id : index_ids) { - file_paths.push_back(inverted_index_path_v1(tablet_id, rowset_id, i, - index_id.first, index_id.second)); + add_file_to_delete_if_not_packed( + rs, + inverted_index_path_v1(tablet_id, rowset_id, i, index_id.first, + index_id.second), + &file_paths); } } else if (!index_ids.empty() || inverted_index_get_ret == 1) { // try to recycle inverted index v2 when get_ret == 1 @@ -3917,7 +3941,8 @@ int InstanceRecycler::delete_rowset_data( .tag("inverted index v2 path", inverted_index_path_v2(tablet_id, rowset_id, i)); } - file_paths.push_back(inverted_index_path_v2(tablet_id, rowset_id, i)); + add_file_to_delete_if_not_packed( + rs, inverted_index_path_v2(tablet_id, rowset_id, i), &file_paths); } } } diff --git a/cloud/test/recycler_test.cpp b/cloud/test/recycler_test.cpp index f84eed2bab2ffe..65a1a7f2931b89 100644 --- a/cloud/test/recycler_test.cpp +++ b/cloud/test/recycler_test.cpp @@ -5843,6 +5843,9 @@ TEST(RecyclerTest, delete_rowset_data_packed_file_single_rowset) { EXPECT_EQ(TxnErrorCode::TXN_KEY_NOT_FOUND, txn->get(merged_key, &updated_val)); EXPECT_EQ(1, accessor->exists(packed_file_path)); + for (int i = 0; i < rowset.num_segments(); ++i) { + EXPECT_EQ(0, accessor->exists(segment_path(rowset.tablet_id(), rowset.rowset_id_v2(), i))); + } } TEST(RecyclerTest, delete_rowset_data_packed_file_respects_recycled_tablet) { @@ -6006,6 +6009,7 @@ TEST(RecyclerTest, delete_rowset_data_packed_file_batch_rowsets) { EXPECT_EQ(TxnErrorCode::TXN_KEY_NOT_FOUND, txn->get(merged_key, &updated_val)); EXPECT_EQ(1, accessor->exists(packed_file_path)); + EXPECT_EQ(0, accessor->exists(small_path)); } TEST(RecyclerTest, delete_rowset_data_packed_file_multiple_groups) { @@ -6124,7 +6128,7 @@ TEST(RecyclerTest, delete_rowset_data_packed_file_multiple_groups) { } for (const auto& path : segment_paths) { - EXPECT_EQ(1, accessor->exists(path)); + EXPECT_EQ(0, accessor->exists(path)); } for (const auto& path : index_paths) { EXPECT_EQ(1, accessor->exists(path));