diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp index 62a161e3edbe52..763c3e8065105a 100644 --- a/cloud/src/recycler/recycler.cpp +++ b/cloud/src/recycler/recycler.cpp @@ -1680,6 +1680,30 @@ 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()) { + /* + * 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) { + // 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()) { LOG_WARNING("rowset meta does not have a resource id, impossible!") .tag("rs_meta", rs_meta.ShortDebugString()) @@ -1687,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]] {