From f0eaa2c31cd4c37f8c5aef19fb2180361dcfcd77 Mon Sep 17 00:00:00 2001 From: HappenLee Date: Fri, 24 Jan 2025 16:02:20 +0800 Subject: [PATCH] [Bug](fix) Try to prevent the bug of brpc issue 2146 --- be/src/util/brpc_client_cache.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/be/src/util/brpc_client_cache.h b/be/src/util/brpc_client_cache.h index 24bd284f302fb9..a8aea36ee0cd83 100644 --- a/be/src/util/brpc_client_cache.h +++ b/be/src/util/brpc_client_cache.h @@ -144,6 +144,8 @@ class BrpcClientCache { } else if (_connection_group != "") { options.connection_group = _connection_group; } + // Add random connection id to connection_group to make sure use new socket + options.connection_group += std::to_string(_connection_id.fetch_add(1)); options.connect_timeout_ms = 2000; options.timeout_ms = 2000; options.max_retry = 10; @@ -227,6 +229,9 @@ class BrpcClientCache { const std::string _protocol; const std::string _connection_type; const std::string _connection_group; + // use to generate unique connection id for each connection + // to prevent the connection problem of brpc: https://github.com/apache/brpc/issues/2146 + std::atomic _connection_id {0}; }; using InternalServiceClientCache = BrpcClientCache;