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

feat: add a service option to disable check eovercrowded on server side #2774

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions src/brpc/policy/baidu_rpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -472,13 +472,13 @@ void ProcessRpcRequest(InputMessageBase* msg_base) {
cntl->SetFailed(ELOGOFF, "Server is stopping");
break;
}

if (socket->is_overcrowded()) {
if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
}

if (!server_accessor.AddConcurrency(cntl.get())) {
cntl->SetFailed(
ELIMIT, "Reached server's max_concurrency=%d",
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/policy/http_rpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1495,7 +1495,7 @@ void ProcessHttpRequest(InputMessageBase *msg) {
// NOTE: accesses to builtin services are not counted as part of
// concurrency, therefore are not limited by ServerOptions.max_concurrency.
if (!sp->is_builtin_service && !sp->params.is_tabbed) {
if (socket->is_overcrowded()) {
if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
return;
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/policy/hulu_pbrpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -422,7 +422,7 @@ void ProcessHuluRequest(InputMessageBase* msg_base) {
break;
}

if (socket->is_overcrowded()) {
if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/policy/nshead_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ void ProcessNsheadRequest(InputMessageBase* msg_base) {
cntl->SetFailed(ELOGOFF, "Server is stopping");
break;
}
if (socket->is_overcrowded()) {
if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/policy/sofa_pbrpc_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ void ProcessSofaRequest(InputMessageBase* msg_base) {
break;
}

if (socket->is_overcrowded()) {
if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) {
cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
break;
Expand Down
2 changes: 1 addition & 1 deletion src/brpc/policy/thrift_protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ void ProcessThriftRequest(InputMessageBase* msg_base) {
if (!server->IsRunning()) {
return cntl->SetFailed(ELOGOFF, "Server is stopping");
}
if (socket->is_overcrowded()) {
if (socket->is_overcrowded() && !server->options().ignore_eovercrowded) {
return cntl->SetFailed(EOVERCROWDED, "Connection to %s is overcrowded",
butil::endpoint2str(socket->remote_side()).c_str());
}
Expand Down
3 changes: 2 additions & 1 deletion src/brpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,8 @@ ServerOptions::ServerOptions()
, rtmp_service(NULL)
, redis_service(NULL)
, bthread_tag(BTHREAD_TAG_INVALID)
, rpc_pb_message_factory(new DefaultRpcPBMessageFactory()) {
, rpc_pb_message_factory(new DefaultRpcPBMessageFactory())
, ignore_eovercrowded(false) {
if (s_ncore > 0) {
num_threads = s_ncore + 1;
}
Expand Down
5 changes: 5 additions & 0 deletions src/brpc/server.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,11 @@ struct ServerOptions {
// Owned by Server and deleted in server's destructor.
RpcPBMessageFactory* rpc_pb_message_factory;

// Ignore eovercrowded error on server side, i.e. , if eovercrowded is reported when server is processing a rpc request,
// server will keep processing this request, it is expected to be used by some light-weight control-frame rpcs.
// [CUATION] You should not enabling this option if your rpc is heavy-loaded.
bool ignore_eovercrowded;
chenBright marked this conversation as resolved.
Show resolved Hide resolved

private:
// SSLOptions is large and not often used, allocate it on heap to
// prevent ServerOptions from being bloated in most cases.
Expand Down
Loading