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


##########
cloud/src/meta-service/meta_service_tablet_stats.cpp:
##########
@@ -156,4 +163,517 @@ void internal_get_tablet_stats(MetaServiceCode& code, 
std::string& msg, Transact
     merge_tablet_stats(stats, detached_stats);
 }
 
+MetaServiceResponseStatus fix_tablet_stats_parse_param(
+        std::shared_ptr<ResourceManager> resource_mgr, const std::string& 
table_id_str,
+        const std::string& cloud_unique_id_str, int64_t& table_id, 
std::string& instance_id) {
+    MetaServiceCode code = MetaServiceCode::OK;
+    std::string msg;
+    MetaServiceResponseStatus st;
+    st.set_code(MetaServiceCode::OK);
+
+    // parse params
+    try {
+        table_id = std::stoll(table_id_str);
+    } catch (...) {
+        st.set_code(MetaServiceCode::INVALID_ARGUMENT);
+        st.set_msg("Invalid table_id, table_id: " + table_id_str);
+        return st;
+    }
+
+    instance_id = get_instance_id(resource_mgr, cloud_unique_id_str);
+    if (instance_id.empty()) {
+        code = MetaServiceCode::INVALID_ARGUMENT;
+        msg = "empty instance_id";
+        LOG(INFO) << msg << ", cloud_unique_id=" << cloud_unique_id_str;
+        st.set_code(code);
+        st.set_msg(msg);
+        return st;
+    }
+    return st;
+}
+
+MetaServiceResponseStatus read_range_tablet_stats(std::shared_ptr<TxnKv> 
txn_kv,
+                                                  const std::string& 
instance_id, int64_t table_id,
+                                                  const std::string& begin_key,
+                                                  const std::string& end_key,
+                                                  
std::unique_ptr<RangeGetIterator>& it) {
+    MetaServiceCode code = MetaServiceCode::OK;
+    std::string msg;
+    MetaServiceResponseStatus st;
+    st.set_code(MetaServiceCode::OK);
+    std::unique_ptr<Transaction> txn;
+
+    TxnErrorCode err = txn_kv->create_txn(&txn);
+    if (err != TxnErrorCode::TXN_OK) {
+        code = cast_as<ErrCategory::CREATE>(err);
+        msg = fmt::format("[fix tablet stat] failed to create txn");
+        st.set_code(code);
+        st.set_msg(msg);
+        return st;
+    }
+
+    err = txn->get(begin_key, end_key, &it, true);
+    if (err != TxnErrorCode::TXN_OK) {
+        st.set_code(cast_as<ErrCategory::READ>(err));
+        st.set_msg(fmt::format("failed to get tablet stats, err={} 
instance_id={} table_id={} ",
+                               err, instance_id, table_id));
+        return st;
+    }
+
+    err = txn->commit();

Review Comment:
   we dont need a commit for read only kv txn



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