From 7be7969f918d71ccc711e6fcf43cc48e31fe490b Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Wed, 22 Jan 2025 19:54:07 +0800 Subject: [PATCH 1/2] 1 --- cloud/src/recycler/recycler.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp index 62a161e3edbe52..8e6e6d123abe96 100644 --- a/cloud/src/recycler/recycler.cpp +++ b/cloud/src/recycler/recycler.cpp @@ -1680,6 +1680,12 @@ int InstanceRecycler::recycle_tablet(int64_t tablet_id) { TEST_SYNC_POINT_CALLBACK("InstanceRecycler::recycle_tablet.create_rowset_meta", &resp); for (const auto& rs_meta : resp.rowset_meta()) { + // rowset [0-1] doesn't have resource id and object file + // rowset [0-1] only has meta + if (rs_meta.end_version() == 1) { + LOG_INFO("recycle [0-1] rs meta").tag("rs_meta", rs_meta.ShortDebugString()); + continue; + } if (!rs_meta.has_resource_id()) { LOG_WARNING("rowset meta does not have a resource id, impossible!") .tag("rs_meta", rs_meta.ShortDebugString()) From 447fadbf54edbf0d3d99213d3cc4bb2017b60cdc Mon Sep 17 00:00:00 2001 From: Yukang-Lian Date: Wed, 22 Jan 2025 21:29:53 +0800 Subject: [PATCH 2/2] 2 --- cloud/src/recycler/recycler.cpp | 25 ++++++++++++++++++++++--- 1 file changed, 22 insertions(+), 3 deletions(-) diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp index 8e6e6d123abe96..763c3e8065105a 100644 --- a/cloud/src/recycler/recycler.cpp +++ b/cloud/src/recycler/recycler.cpp @@ -1680,10 +1680,28 @@ int InstanceRecycler::recycle_tablet(int64_t tablet_id) { TEST_SYNC_POINT_CALLBACK("InstanceRecycler::recycle_tablet.create_rowset_meta", &resp); for (const auto& rs_meta : resp.rowset_meta()) { - // rowset [0-1] doesn't have resource id and object file - // rowset [0-1] only has meta + /* + * For compatibility, we skip the loop for [0-1] here. + * The purpose of this loop is to delete object files, + * and since [0-1] only has meta and doesn't have object files, + * skipping it doesn't affect system correctness. + * + * If not skipped, the check "if (!rs_meta.has_resource_id())" below + * would return error -1 directly, causing the recycle operation to fail. + * + * [0-1] doesn't have resource id is a bug. + * In the future, we will fix this problem, after that, + * we can remove this if statement. + * + * TODO(Yukang-Lian): remove this if statement when [0-1] has resource id in the future. + */ + if (rs_meta.end_version() == 1) { - LOG_INFO("recycle [0-1] rs meta").tag("rs_meta", rs_meta.ShortDebugString()); + // Assert that [0-1] has no resource_id to make sure + // this if statement will not be forgetted to remove + // when the resource id bug is fixed + DCHECK(!rs_meta.has_resource_id()) << "rs_meta" << rs_meta.ShortDebugString(); + recycle_rowsets_number += 1; continue; } if (!rs_meta.has_resource_id()) { @@ -1693,6 +1711,7 @@ int InstanceRecycler::recycle_tablet(int64_t tablet_id) { .tag("tablet_id", tablet_id); return -1; } + DCHECK(rs_meta.has_resource_id()) << "rs_meta" << rs_meta.ShortDebugString(); auto it = accessor_map_.find(rs_meta.resource_id()); // possible if the accessor is not initilized correctly if (it == accessor_map_.end()) [[unlikely]] {