github-actions[bot] commented on code in PR #62234:
URL: https://github.com/apache/doris/pull/62234#discussion_r3055930133


##########
cloud/src/recycler/recycler.cpp:
##########
@@ -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_

Review Comment:
   This guard looks too broad for the full instance lifecycle. I could not find 
any production code that clears `successor_instance_id` once the 
rollback/snapshot handoff is finished: `SnapshotManager::decouple_instance()` 
only clears `source_instance_id` / `source_snapshot_id` on the successor, and 
the only `set_successor_instance_id()` use in the repo is test setup. As a 
result, a deleted source instance will keep returning early here for as long as 
the successor instance itself exists, so its meta/versioned KV ranges are never 
reclaimed. That turns the original data-loss bug into a permanent recycle leak. 
Please key this skip off the actual remaining dependency, or add the 
corresponding cleanup of `successor_instance_id` when the successor no longer 
needs the source instance metadata.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

Reply via email to