Skip to content

Commit 591a874

Browse files
[BugFix] fix bundle file vacuum when Fe downgrade (backport #67849) (#67887)
Signed-off-by: luohaha <18810541851@163.com> Co-authored-by: Yixin Luo <18810541851@163.com>
1 parent d9ed13f commit 591a874

3 files changed

Lines changed: 42 additions & 0 deletions

File tree

be/src/storage/lake/async_file_deleter.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,11 @@ class AsyncBundleFileDeleter : public AsyncFileDeleter {
120120

121121
bool is_empty() const { return _pending_files.empty(); }
122122

123+
void clear() {
124+
_pending_files.clear();
125+
_delay_delete_files.clear();
126+
}
127+
123128
private:
124129
// file to shared count.
125130
std::unordered_map<std::string, uint32_t> _pending_files;

be/src/storage/lake/vacuum.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -471,6 +471,13 @@ static Status vacuum_tablet_metadata(TabletManager* tablet_mgr, std::string_view
471471
final_vacuum_version = std::min(final_vacuum_version, tablet_vacuumed_version);
472472
max_vacuum_version = std::max(max_vacuum_version, tablet_vacuumed_version);
473473
}
474+
if (!bundle_file_deleter.is_empty() && !enable_file_bundling) {
475+
// If the enable_file_bundling flag is not set in the vacuum request issued by the FE,
476+
// it indicates that the request does not contain the complete tablet information for the partition.
477+
// Due to this lack of sufficient information, bundle files cannot be deleted.
478+
// It may happen when downgrade FE from a version that supports file bundling to a version that does not.
479+
bundle_file_deleter.clear();
480+
}
474481
// delete bundle files
475482
if (max_vacuum_version > 0 && !bundle_file_deleter.is_empty()) {
476483
RETURN_IF_ERROR(collect_alive_bundle_files(tablet_mgr, tablet_infos, max_vacuum_version, root_dir,

be/test/storage/lake/vacuum_test.cpp

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,6 +2943,36 @@ TEST_P(LakeVacuumTest, test_vacuum_shared_data_files) {
29432943
tablet_metas_v4[601] = *t601_v4;
29442944
ASSERT_OK(_tablet_mgr->put_bundle_tablet_metadata(tablet_metas_v4));
29452945

2946+
// enable_file_bundling is false, shared files will not be deleted.
2947+
{
2948+
VacuumRequest request;
2949+
VacuumResponse response;
2950+
request.set_delete_txn_log(false);
2951+
request.add_tablet_ids(600);
2952+
request.add_tablet_ids(601);
2953+
TabletInfoPB tablet_info1;
2954+
tablet_info1.set_tablet_id(600);
2955+
tablet_info1.set_min_version(3);
2956+
TabletInfoPB tablet_info2;
2957+
tablet_info2.set_tablet_id(601);
2958+
tablet_info2.set_min_version(3);
2959+
request.add_tablet_infos()->CopyFrom(tablet_info1);
2960+
request.add_tablet_infos()->CopyFrom(tablet_info2);
2961+
request.set_min_retain_version(4);
2962+
request.set_grace_timestamp(grace_timestamp + 1);
2963+
request.set_min_active_txn_id(12345);
2964+
// If enable_file_bundling is false, we need to clear the bundle_file_deleter.
2965+
request.set_enable_file_bundling(false);
2966+
vacuum(_tablet_mgr.get(), request, &response);
2967+
ASSERT_TRUE(response.has_status());
2968+
EXPECT_EQ(0, response.status().status_code()) << response.status().error_msgs(0);
2969+
2970+
EXPECT_TRUE(file_exist("00000000000259e4_27dc159f-6bfc-4a3a-9d9c-c97c10bb2e1d.dat"));
2971+
EXPECT_TRUE(file_exist("00000000000259e4_27dc159f-6bfc-4a3a-9d9c-c97c10bb2e1e.dat"));
2972+
EXPECT_TRUE(file_exist("00000000000259e4_a542395a-bff5-48a7-a3a7-2ed05691b58c.dat"));
2973+
EXPECT_TRUE(file_exist("00000000000259e4_a542395a-bff5-48a7-a3a7-2ed05691b58d.dat"));
2974+
}
2975+
29462976
// shared files will be deleted.
29472977
{
29482978
VacuumRequest request;

0 commit comments

Comments
 (0)