w41ter commented on code in PR #60208:
URL: https://github.com/apache/doris/pull/60208#discussion_r2726199693


##########
cloud/src/recycler/recycler.cpp:
##########
@@ -1077,6 +1077,59 @@ int 
InstanceRecycler::check_recycle_and_tmp_rowset_exists(int64_t tablet_id,
     return 0;
 }
 
+int InstanceRecycler::check_rowset_snapshot_ref(int64_t tablet_id, const 
std::string& rowset_id,
+                                                bool* has_snapshot_ref) {
+    *has_snapshot_ref = false;
+
+    std::unique_ptr<Transaction> txn;
+    TxnErrorCode err = txn_kv_->create_txn(&txn);
+    if (err != TxnErrorCode::TXN_OK) {
+        LOG_WARNING("failed to create txn when checking rowset snapshot ref")
+                .tag("instance_id", instance_id_)
+                .tag("tablet_id", tablet_id)
+                .tag("rowset_id", rowset_id)
+                .tag("err", err);
+        return -1;
+    }
+
+    std::string rowset_ref_count_key =
+            versioned::data_rowset_ref_count_key({instance_id_, tablet_id, 
rowset_id});
+    std::string value;
+    err = txn->get(rowset_ref_count_key, &value);
+    if (err == TxnErrorCode::TXN_KEY_NOT_FOUND) {
+        // No ref count key means this is an old version rowset or ref_count 
== 1
+        *has_snapshot_ref = false;

Review Comment:
   > No ref count key means this is an old version rowset or ref_count == 1
   
   Yes, but `*has_snapshot_ref = false` is wrong.
   
   A snapshot that references a rowset does not need to increment the data 
rowset reference count key. I believe the correct approach is to check whether 
a versioned rowset exists here.



-- 
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