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 4e9114909d4 branch-4.1: [fix](cloud) Avoid recycle the instance which 
has successor #62234 (#62268)
4e9114909d4 is described below

commit 4e9114909d4b4a5cab6f1d2f2df42c6016cdb364
Author: github-actions[bot] 
<41898282+github-actions[bot]@users.noreply.github.com>
AuthorDate: Fri Apr 10 12:01:12 2026 +0800

    branch-4.1: [fix](cloud) Avoid recycle the instance which has successor 
#62234 (#62268)
    
    Cherry-picked from #62234
    
    Co-authored-by: walter <[email protected]>
---
 cloud/src/recycler/recycler.cpp | 35 +++++++++++++++++++++++++++++++++++
 1 file changed, 35 insertions(+)

diff --git a/cloud/src/recycler/recycler.cpp b/cloud/src/recycler/recycler.cpp
index 7d4b6b9a598..00cf9045622 100644
--- a/cloud/src/recycler/recycler.cpp
+++ b/cloud/src/recycler/recycler.cpp
@@ -833,18 +833,21 @@ int InstanceRecycler::recycle_deleted_instance() {
     };
     if (recycle_tmp_rowsets_with_mark_delete_enabled() != 0) {
         LOG_WARNING("failed to recycle tmp rowsets").tag("instance_id", 
instance_id_);
+        ret = -1;
         return -1;
     }
 
     // Step 2: Recycle versioned rowsets in recycle space (already marked for 
deletion)
     if (recycle_versioned_rowsets() != 0) {
         LOG_WARNING("failed to recycle versioned rowsets").tag("instance_id", 
instance_id_);
+        ret = -1;
         return -1;
     }
 
     // Step 3: Recycle operation logs (can recycle logs not referenced by 
snapshots)
     if (recycle_operation_logs() != 0) {
         LOG_WARNING("failed to recycle operation logs").tag("instance_id", 
instance_id_);
+        ret = -1;
         return -1;
     }
 
@@ -852,6 +855,7 @@ int InstanceRecycler::recycle_deleted_instance() {
     bool has_snapshots = false;
     if (has_cluster_snapshots(&has_snapshots) != 0) {
         LOG(WARNING) << "check instance cluster snapshots failed, 
instance_id=" << instance_id_;
+        ret = -1;
         return -1;
     } else if (has_snapshots) {
         LOG(INFO) << "instance has cluster snapshots, skip recycling, 
instance_id=" << instance_id_;
@@ -865,6 +869,7 @@ int InstanceRecycler::recycle_deleted_instance() {
         bool has_unrecycled_rowsets = false;
         if (recycle_ref_rowsets(&has_unrecycled_rowsets) != 0) {
             LOG_WARNING("failed to recycle ref rowsets").tag("instance_id", 
instance_id_);
+            ret = -1;
             return -1;
         } else if (has_unrecycled_rowsets) {
             LOG_INFO("instance has referenced rowsets, skip recycling")
@@ -894,6 +899,36 @@ int InstanceRecycler::recycle_deleted_instance() {
         }
     }
 
+    // Check successor instance, if exists, skip deleting kv because successor 
instance may still need the data in kv
+    if (instance_info_.has_successor_instance_id() &&
+        !instance_info_.successor_instance_id().empty()) {
+        std::string key = instance_key(instance_info_.successor_instance_id());
+        std::unique_ptr<Transaction> txn;
+        TxnErrorCode err = txn_kv_->create_txn(&txn);
+        if (err != TxnErrorCode::TXN_OK) {
+            LOG(WARNING) << "failed to create txn, instance_id=" << 
instance_id_
+                         << " successor_instance_id=" << 
instance_info_.successor_instance_id()
+                         << " err=" << err;
+            ret = -1;
+            return -1;
+        }
+
+        std::string value;
+        err = txn->get(key, &value);
+        if (err == TxnErrorCode::TXN_OK) {
+            LOG(INFO) << "instance successor instance is still exist, skip 
deleting kv,"
+                      << " instance_id=" << instance_id_
+                      << " successor_instance_id=" << 
instance_info_.successor_instance_id();
+            return 0;
+        } else if (err != TxnErrorCode::TXN_KEY_NOT_FOUND) {
+            LOG(WARNING) << "failed to get successor instance, instance_id=" 
<< instance_id_
+                         << " successor_instance_id=" << 
instance_info_.successor_instance_id()
+                         << " err=" << err;
+            ret = -1;
+            return -1;
+        }
+    }
+
     // delete all kv
     std::unique_ptr<Transaction> txn;
     TxnErrorCode err = txn_kv_->create_txn(&txn);


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

Reply via email to