Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Config](brpc) Add connection_type config for brpc and prevent the bug of brpc issue 2146 #47460

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading