This is an automated email from the ASF dual-hosted git repository.

dataroaring pushed a commit to branch branch-3.0
in repository https://gitbox.apache.org/repos/asf/doris.git

commit bc300b41cc7ecb8bf0d2c4e5004f8f81ab6ae581
Author: AlexYue <[email protected]>
AuthorDate: Thu May 16 17:04:27 2024 +0800

    [bugfix](Cloud) Offer sync vault task to thread pool to prevent bthread 
context switch (#34951)
---
 be/src/cloud/cloud_internal_service.cpp | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/be/src/cloud/cloud_internal_service.cpp 
b/be/src/cloud/cloud_internal_service.cpp
index 2a16c166331..46695e36847 100644
--- a/be/src/cloud/cloud_internal_service.cpp
+++ b/be/src/cloud/cloud_internal_service.cpp
@@ -34,7 +34,18 @@ void 
CloudInternalServiceImpl::alter_vault_sync(google::protobuf::RpcController*
                                                 PAlterVaultSyncResponse* 
response,
                                                 google::protobuf::Closure* 
done) {
     LOG(INFO) << "alter be to sync vault info from Meta Service";
-    _engine.sync_storage_vault();
+    // If the vaults containing hdfs vault then it would try to create hdfs 
connection using jni
+    // which would acuiqre one thread local jniEnv. But bthread context can't 
guarantee that the brpc
+    // worker thread wouldn't do bthread switch between worker threads.
+    bool ret = _heavy_work_pool.try_offer([&]() {
+        brpc::ClosureGuard closure_guard(done);
+        _engine.sync_storage_vault();
+    });
+    if (!ret) {
+        brpc::ClosureGuard closure_guard(done);
+        LOG(WARNING) << "fail to offer alter_vault_sync request to the work 
pool, pool="
+                     << _heavy_work_pool.get_info();
+    }
 }
 
 FileCacheType cache_type_to_pb(io::FileCacheType type) {


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

Reply via email to