Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 33 additions & 8 deletions cloud/src/recycler/recycler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::string>* 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
Expand Down Expand Up @@ -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);
}
}

Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion cloud/test/recycler_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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));
Expand Down
Loading