This is an automated email from the ASF dual-hosted git repository.
dataroaring pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new 57bd84a4f21 [fix](cloud) create_instance notify refresh instance
(#56341)
57bd84a4f21 is described below
commit 57bd84a4f2172ab3b67ea21506523073d2dba37e
Author: walter <[email protected]>
AuthorDate: Wed Sep 24 11:48:53 2025 +0800
[fix](cloud) create_instance notify refresh instance (#56341)
---
cloud/src/meta-service/meta_service_resource.cpp | 59 +++++++++++++++---------
1 file changed, 37 insertions(+), 22 deletions(-)
diff --git a/cloud/src/meta-service/meta_service_resource.cpp
b/cloud/src/meta-service/meta_service_resource.cpp
index 1e1b30bcf7b..7b19dd435e9 100644
--- a/cloud/src/meta-service/meta_service_resource.cpp
+++ b/cloud/src/meta-service/meta_service_resource.cpp
@@ -199,6 +199,25 @@ static int decrypt_and_update_ak_sk(ObjectStoreInfoPB&
obj_info, MetaServiceCode
return 0;
};
+// Asynchronously notify refresh instance in background thread
+static void async_notify_refresh_instance(
+ std::shared_ptr<TxnKv> txn_kv, const std::string& instance_id,
+ std::function<void(const KVStats&)> stats_handler = nullptr) {
+ auto f = new std::function<void()>(
+ [instance_id, txn_kv = std::move(txn_kv), stats_handler =
std::move(stats_handler)] {
+ KVStats stats;
+ notify_refresh_instance(txn_kv, instance_id, &stats);
+ if (stats_handler) {
+ stats_handler(stats);
+ }
+ });
+ bthread_t bid;
+ if (bthread_start_background(&bid, nullptr, run_bthread_work, f) != 0) {
+ LOG(WARNING) << "notify refresh instance inplace, instance_id=" <<
instance_id;
+ run_bthread_work(f);
+ }
+}
+
void MetaServiceImpl::get_obj_store_info(google::protobuf::RpcController*
controller,
const GetObjStoreInfoRequest* request,
GetObjStoreInfoResponse* response,
@@ -1786,6 +1805,15 @@ void
MetaServiceImpl::create_instance(google::protobuf::RpcController* controlle
msg = fmt::format("failed to commit kv txn, err={}", err);
LOG(WARNING) << msg;
}
+
+ async_notify_refresh_instance(
+ txn_kv_, request->instance_id(),
+ [instance_id = request->instance_id()](const KVStats& stats) {
+ if (config::use_detailed_metrics && !instance_id.empty()) {
+ g_bvar_rpc_kv_create_instance_get_bytes.put({instance_id},
stats.get_bytes);
+
g_bvar_rpc_kv_create_instance_get_counter.put({instance_id}, stats.get_counter);
+ }
+ });
}
std::pair<MetaServiceCode, std::string> handle_snapshot_switch(const
std::string& instance_id,
@@ -2142,14 +2170,7 @@ void
MetaServiceImpl::alter_instance(google::protobuf::RpcController* controller
if (request->op() == AlterInstanceRequest::REFRESH) return;
- auto f = new std::function<void()>([instance_id = request->instance_id(),
txn_kv = txn_kv_] {
- notify_refresh_instance(txn_kv, instance_id, nullptr);
- });
- bthread_t bid;
- if (bthread_start_background(&bid, nullptr, run_bthread_work, f) != 0) {
- LOG(WARNING) << "notify refresh instance inplace, instance_id=" <<
request->instance_id();
- run_bthread_work(f);
- }
+ async_notify_refresh_instance(txn_kv_, request->instance_id());
}
void MetaServiceImpl::get_instance(google::protobuf::RpcController* controller,
@@ -2767,20 +2788,14 @@ void
MetaServiceImpl::alter_cluster(google::protobuf::RpcController* controller,
if (code != MetaServiceCode::OK) return;
- auto f = new std::function<void()>([instance_id = request->instance_id(),
txn_kv = txn_kv_] {
- // the func run with a thread, so if use macro proved stats, maybe
cause stack-use-after-return error
- KVStats stats;
- notify_refresh_instance(txn_kv, instance_id, &stats);
- if (config::use_detailed_metrics && !instance_id.empty()) {
- g_bvar_rpc_kv_alter_cluster_get_bytes.put({instance_id},
stats.get_bytes);
- g_bvar_rpc_kv_alter_cluster_get_counter.put({instance_id},
stats.get_counter);
- }
- });
- bthread_t bid;
- if (bthread_start_background(&bid, nullptr, run_bthread_work, f) != 0) {
- LOG(WARNING) << "notify refresh instance inplace, instance_id=" <<
request->instance_id();
- run_bthread_work(f);
- }
+ async_notify_refresh_instance(
+ txn_kv_, request->instance_id(),
+ [instance_id = request->instance_id()](const KVStats& stats) {
+ if (config::use_detailed_metrics && !instance_id.empty()) {
+ g_bvar_rpc_kv_alter_cluster_get_bytes.put({instance_id},
stats.get_bytes);
+ g_bvar_rpc_kv_alter_cluster_get_counter.put({instance_id},
stats.get_counter);
+ }
+ });
}
void MetaServiceImpl::get_cluster(google::protobuf::RpcController* controller,
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]