Skip to content

Commit

Permalink
[Bug](fix) Try to prevent the bug of brpc issue 2146
Browse files Browse the repository at this point in the history
  • Loading branch information
HappenLee committed Jan 26, 2025
1 parent 69e99df commit a34dff2
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions be/src/util/brpc_client_cache.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<int64_t> _connection_id {0};
};

using InternalServiceClientCache = BrpcClientCache<PBackendService_Stub>;
Expand Down

0 comments on commit a34dff2

Please sign in to comment.