This is an automated email from the ASF dual-hosted git repository.

yiguolei pushed a commit to branch branch-4.1
in repository https://gitbox.apache.org/repos/asf/doris.git


The following commit(s) were added to refs/heads/branch-4.1 by this push:
     new 56486274184 branch-4.1: [fix](cloud) Recycle empty rowsets without 
resource id #64630 (#64643)
56486274184 is described below

commit 564862741841a28748e77eb6ee81fbdaab641f44
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Sat Jun 20 21:47:59 2026 +0800

    branch-4.1: [fix](cloud) Recycle empty rowsets without resource id #64630 
(#64643)
    
    Cherry-picked from #64630
    
    Co-authored-by: Xin Liao <[email protected]>
---
 cloud/src/recycler/recycler.cpp | 14 +++++++-------
 cloud/test/recycler_test.cpp    | 31 +++++++++++++++++++++++++++++++
 2 files changed, 38 insertions(+), 7 deletions(-)

diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp
index 4325c16eb52..be633966d90 100644
--- a/cloud/src/recycler/recycler.cpp
+++ b/cloud/src/recycler/recycler.cpp
@@ -4300,24 +4300,24 @@ int InstanceRecycler::recycle_tablet(int64_t tablet_id, 
RecyclerMetricsContext&
     
TEST_SYNC_POINT_CALLBACK("InstanceRecycler::recycle_tablet.create_rowset_meta", 
&resp);
 
     for (const auto& rs_meta : resp.rowset_meta()) {
-        // The rowset has no resource id and segments when it was generated by 
compaction
-        // with multiple hole rowsets or it's version is [0-1], so we can skip 
it.
-        if (!rs_meta.has_resource_id() && rs_meta.num_segments() == 0) {
-            LOG_INFO("rowset meta does not have a resource id and no segments, 
skip this rowset")
+        // Empty rowsets have no segment objects to delete, so they do not 
need a resource id.
+        if (rs_meta.num_segments() <= 0) {
+            LOG_INFO("rowset meta has no segments, skip this rowset")
                     .tag("rs_meta", rs_meta.ShortDebugString())
                     .tag("instance_id", instance_id_)
                     .tag("tablet_id", tablet_id);
             recycle_rowsets_number += 1;
             continue;
         }
-        if (!rs_meta.has_resource_id()) {
-            LOG_WARNING("rowset meta does not have a resource id, impossible!")
+        if (!rs_meta.has_resource_id() || rs_meta.resource_id().empty()) {
+            LOG_WARNING("rowset meta has a missing or empty resource id, 
impossible!")
                     .tag("rs_meta", rs_meta.ShortDebugString())
                     .tag("instance_id", instance_id_)
                     .tag("tablet_id", tablet_id);
             return -1;
         }
-        DCHECK(rs_meta.has_resource_id()) << "rs_meta" << 
rs_meta.ShortDebugString();
+        DCHECK(rs_meta.has_resource_id() && !rs_meta.resource_id().empty())
+                << "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]] {
diff --git a/cloud/test/recycler_test.cpp b/cloud/test/recycler_test.cpp
index 856347af27d..77ad6cd4261 100644
--- a/cloud/test/recycler_test.cpp
+++ b/cloud/test/recycler_test.cpp
@@ -6837,6 +6837,37 @@ TEST(RecyclerTest, recycle_tablet_without_resource_id) {
     
EXPECT_EQ(recycler.accessor_map_.at("success_vault")->exists("data/0/test.csv"),
 0);
 }
 
+TEST(RecyclerTest, recycle_tablet_with_empty_resource_id_and_no_segments) {
+    auto* sp = SyncPoint::get_instance();
+    DORIS_CLOUD_DEFER {
+        sp->clear_all_call_backs();
+        sp->clear_trace();
+        sp->disable_processing();
+    };
+
+    auto txn_kv = std::make_shared<MemTxnKv>();
+    EXPECT_EQ(txn_kv->init(), 0);
+    InstanceInfoPB instance;
+    instance.set_instance_id("test_instance");
+
+    sp->set_call_back("InstanceRecycler::recycle_tablet.create_rowset_meta", 
[](auto&& args) {
+        auto* resp = try_any_cast<GetRowsetResponse*>(args[0]);
+        auto* rs = resp->add_rowset_meta();
+        rs->set_num_segments(0);
+        rs->set_resource_id("");
+        EXPECT_TRUE(rs->has_resource_id());
+        EXPECT_TRUE(rs->resource_id().empty());
+    });
+    sp->enable_processing();
+
+    InstanceRecycler recycler(txn_kv, instance, thread_group,
+                              std::make_shared<TxnLazyCommitter>(txn_kv));
+    EXPECT_EQ(recycler.init(), 0);
+
+    RecyclerMetricsContext ctx;
+    EXPECT_EQ(recycler.recycle_tablet(0, ctx), 0);
+}
+
 TEST(RecyclerTest, recycle_tablet_with_wrong_resource_id) {
     auto* sp = SyncPoint::get_instance();
     DORIS_CLOUD_DEFER {


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to