Skip to content

Commit

Permalink
[bugfix](Cloud) Offer sync vault task to thread pool to prevent bthre…
Browse files Browse the repository at this point in the history
…ad context switch (apache#34951)
  • Loading branch information
ByteYue authored May 16, 2024
1 parent 1c962a5 commit fe80d4f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion be/src/cloud/cloud_internal_service.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit fe80d4f

Please sign in to comment.