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 9c66121027e [improvement](thrift) Limit max cached client size for BE thrift connection to master FE. (#43973) 9c66121027e is described below commit 9c66121027e3f691256afb92a7e31f9344ab83bf Author: Shuo Wang <wangshuo...@gmail.com> AuthorDate: Sat Mar 1 10:17:16 2025 +0800 [improvement](thrift) Limit max cached client size for BE thrift connection to master FE. (#43973) ### What problem does this PR solve? - Avoid too many connections: limit max cached client size for BE thrift connection to master FE. Before this PR, the thrift clients to master FE were always cached and never released. - Add metrics for client numbers. Co-authored-by: wangshuo33 <wangshu...@meituan.com> --- be/src/agent/utils.cpp | 13 ++++++++----- be/src/agent/utils.h | 2 ++ be/src/common/config.cpp | 2 ++ be/src/common/config.h | 2 ++ 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/be/src/agent/utils.cpp b/be/src/agent/utils.cpp index c5653a02792..1d23f2b017f 100644 --- a/be/src/agent/utils.cpp +++ b/be/src/agent/utils.cpp @@ -59,7 +59,6 @@ using apache::thrift::transport::TTransportException; namespace doris { -static FrontendServiceClientCache s_client_cache; static std::unique_ptr<MasterServerClient> s_client; MasterServerClient* MasterServerClient::create(const ClusterInfo* cluster_info) { @@ -72,11 +71,15 @@ MasterServerClient* MasterServerClient::instance() { } MasterServerClient::MasterServerClient(const ClusterInfo* cluster_info) - : _cluster_info(cluster_info) {} + : _cluster_info(cluster_info), + _client_cache(std::make_unique<FrontendServiceClientCache>( + config::max_master_fe_client_cache_size)) { + _client_cache->init_metrics("master_fe"); +} Status MasterServerClient::finish_task(const TFinishTaskRequest& request, TMasterResult* result) { Status client_status; - FrontendServiceConnection client(&s_client_cache, _cluster_info->master_fe_addr, + FrontendServiceConnection client(_client_cache.get(), _cluster_info->master_fe_addr, config::thrift_rpc_timeout_ms, &client_status); if (!client_status.ok()) { @@ -119,7 +122,7 @@ Status MasterServerClient::finish_task(const TFinishTaskRequest& request, TMaste Status MasterServerClient::report(const TReportRequest& request, TMasterResult* result) { Status client_status; - FrontendServiceConnection client(&s_client_cache, _cluster_info->master_fe_addr, + FrontendServiceConnection client(_client_cache.get(), _cluster_info->master_fe_addr, config::thrift_rpc_timeout_ms, &client_status); if (!client_status.ok()) { @@ -177,7 +180,7 @@ Status MasterServerClient::report(const TReportRequest& request, TMasterResult* Status MasterServerClient::confirm_unused_remote_files( const TConfirmUnusedRemoteFilesRequest& request, TConfirmUnusedRemoteFilesResult* result) { Status client_status; - FrontendServiceConnection client(&s_client_cache, _cluster_info->master_fe_addr, + FrontendServiceConnection client(_client_cache.get(), _cluster_info->master_fe_addr, config::thrift_rpc_timeout_ms, &client_status); if (!client_status.ok()) { diff --git a/be/src/agent/utils.h b/be/src/agent/utils.h index d554e92ff67..70dfe1a9818 100644 --- a/be/src/agent/utils.h +++ b/be/src/agent/utils.h @@ -23,6 +23,7 @@ #include <string> #include "common/status.h" +#include "runtime/client_cache.h" namespace doris { class TConfirmUnusedRemoteFilesRequest; @@ -67,6 +68,7 @@ private: // Not owner. Reference to the ExecEnv::_cluster_info const ClusterInfo* _cluster_info; + std::unique_ptr<FrontendServiceClientCache> _client_cache; }; class AgentUtils { diff --git a/be/src/common/config.cpp b/be/src/common/config.cpp index c6d0ee8ed1d..474a3b1bb28 100644 --- a/be/src/common/config.cpp +++ b/be/src/common/config.cpp @@ -715,6 +715,8 @@ DEFINE_mInt32(es_http_timeout_ms, "5000"); // TODO(cmy): use different config to set different client cache if necessary. DEFINE_Int32(max_client_cache_size_per_host, "10"); +DEFINE_Int32(max_master_fe_client_cache_size, "10"); + // Dir to save files downloaded by SmallFileMgr DEFINE_String(small_file_dir, "${DORIS_HOME}/lib/small_file/"); // path gc diff --git a/be/src/common/config.h b/be/src/common/config.h index a1aab4a001d..124934f2caf 100644 --- a/be/src/common/config.h +++ b/be/src/common/config.h @@ -754,6 +754,8 @@ DECLARE_mInt32(es_http_timeout_ms); // TODO(cmy): use different config to set different client cache if necessary. DECLARE_Int32(max_client_cache_size_per_host); +DECLARE_Int32(max_master_fe_client_cache_size); + // Dir to save files downloaded by SmallFileMgr DECLARE_String(small_file_dir); // path gc --------------------------------------------------------------------- To unsubscribe, e-mail: commits-unsubscr...@doris.apache.org For additional commands, e-mail: commits-h...@doris.apache.org