gavinchou commented on code in PR #46798:
URL: https://github.com/apache/doris/pull/46798#discussion_r1916449190


##########
cloud/src/recycler/recycler.cpp:
##########
@@ -1588,59 +1611,126 @@ int InstanceRecycler::recycle_tablet(int64_t 
tablet_id) {
             .tag("instance_id", instance_id_)
             .tag("tablet_id", tablet_id);
 
+    int ret = 0;
     auto start_time = steady_clock::now();
 
-    std::unique_ptr<int, std::function<void(int*)>> 
defer_log_statistics((int*)0x01, [&](int*) {
-        auto cost = duration<float>(steady_clock::now() - start_time).count();
-        LOG_INFO("recycle the rowsets of dropped tablet finished, cost={}s", 
cost)
-                .tag("instance_id", instance_id_)
-                .tag("tablet_id", tablet_id);
-    });
+    std::unique_ptr<Transaction> txn;
+    if (txn_kv_->create_txn(&txn) != TxnErrorCode::TXN_OK) {
+        LOG_WARNING("failed to delete rowset kv of tablet ")
+                .tag("tablet id", tablet_id)
+                .tag("reason", "failed to create txn");
+        ret = -1;
+    }
 
-    // delete all rowset kv in this tablet
+    // collect resource ids
     std::string rs_key0 = meta_rowset_key({instance_id_, tablet_id, 0});
     std::string rs_key1 = meta_rowset_key({instance_id_, tablet_id + 1, 0});
     std::string recyc_rs_key0 = recycle_rowset_key({instance_id_, tablet_id, 
""});
     std::string recyc_rs_key1 = recycle_rowset_key({instance_id_, tablet_id + 
1, ""});
 
-    int ret = 0;
-    std::unique_ptr<Transaction> txn;
-    if (txn_kv_->create_txn(&txn) != TxnErrorCode::TXN_OK) {
-        LOG(WARNING) << "failed to delete rowset kv of tablet " << tablet_id;
-        ret = -1;
-    }
-    txn->remove(rs_key0, rs_key1);
-    txn->remove(recyc_rs_key0, recyc_rs_key1);
+    std::set<std::string> resource_ids;
+    int64_t recycle_rowsets_number = 0;
+    int64_t recycle_segments_number = 0;
+    int64_t recycle_rowsets_data_size = 0;
+    int64_t recycle_rowsets_index_size = 0;
+    int64_t max_rowset_version = 0;
+    int64_t min_rowset_creation_time = INT64_MAX;
+    int64_t max_rowset_creation_time = 0;
+    int64_t min_rowset_expiration_time = INT64_MAX;
+    int64_t max_rowset_expiration_time = 0;
 
-    // remove delete bitmap for MoW table
-    std::string pending_key = meta_pending_delete_bitmap_key({instance_id_, 
tablet_id});
-    txn->remove(pending_key);
-    std::string delete_bitmap_start = meta_delete_bitmap_key({instance_id_, 
tablet_id, "", 0, 0});
-    std::string delete_bitmap_end = meta_delete_bitmap_key({instance_id_, 
tablet_id + 1, "", 0, 0});
-    txn->remove(delete_bitmap_start, delete_bitmap_end);
+    std::unique_ptr<int, std::function<void(int*)>> 
defer_log_statistics((int*)0x01, [&](int*) {
+        auto cost = duration<float>(steady_clock::now() - start_time).count();
+        LOG_INFO("recycle the rowsets of dropped tablet finished, cost={}s", 
cost)
+                .tag("instance_id", instance_id_)
+                .tag("tablet_id", tablet_id)
+                .tag("recycle rowsets number", recycle_rowsets_number)
+                .tag("recycle segments number", recycle_segments_number)
+                .tag("all rowsets recycle data size", 
recycle_rowsets_data_size)
+                .tag("all rowsets recycle index size", 
recycle_rowsets_index_size)
+                .tag("max rowset version", max_rowset_version)
+                .tag("min rowset creation time", min_rowset_creation_time)
+                .tag("max rowset creation time", max_rowset_creation_time)
+                .tag("min rowset expiration time", min_rowset_expiration_time)
+                .tag("max rowset expiration time", max_rowset_expiration_time)
+                .tag("ret", ret);
+    });
 
-    TxnErrorCode err = txn->commit();
-    if (err != TxnErrorCode::TXN_OK) {
-        LOG(WARNING) << "failed to delete rowset kv of tablet " << tablet_id 
<< ", err=" << err;
+    GetRowsetResponse resp;
+    std::string msg;
+    MetaServiceCode code = MetaServiceCode::OK;
+    // get rowsets in tablet
+    internal_get_rowset(txn.get(), 0, std::numeric_limits<int64_t>::max() - 1, 
instance_id_,
+                        tablet_id, code, msg, &resp);
+    if (code != MetaServiceCode::OK) {
+        LOG_WARNING("failed to get rowsets of tablet when recycle tablet")
+                .tag("tablet id", tablet_id)
+                .tag("msg", msg)
+                .tag("code", code)
+                .tag("instance id", instance_id_);
         ret = -1;
     }
+    
TEST_SYNC_POINT_CALLBACK("InstanceRecycler::recycle_tablet.create_rowset_meta", 
&resp);
+
+    for (const auto& rs_meta : resp.rowset_meta()) {
+        if (!rs_meta.has_resource_id()) {
+            LOG_WARNING("rowset meta does not have a resource id, impossible!")

Review Comment:
   log instance_id, tablet_id



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