Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Register
Sign in
Toggle navigation
Menu
Open sidebar
pub
google
gRPC
Commits
edf500fb
Unverified
Commit
edf500fb
authored
3 years ago
by
Vijay Pai
Committed by
GitHub
3 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Add useful status error message when server threadpool is exhausted (#26146)
parent
dc63d6a5
master
v1.38.0_rp
v1.51.1
v1.51.0
v1.51.0-pre1
v1.50.1
v1.50.0
v1.50.0-pre1
v1.49.2
v1.49.1
v1.49.0
v1.49.0-pre3
v1.49.0-pre2
v1.49.0-pre1
v1.48.2
v1.48.1
v1.48.0
v1.48.0-pre1
v1.47.2
v1.47.1
v1.47.0
v1.47.0-pre1
v1.46.5
v1.46.4
v1.46.3
v1.46.2
v1.46.1
v1.46.0
v1.46.0-pre2
v1.46.0-pre1
v1.45.2
v1.45.1
v1.45.0
v1.45.0-pre1
v1.44.0
v1.44.0-pre2
v1.44.0-pre1
v1.43.2
v1.43.0
v1.43.0-pre1
v1.42.0
v1.42.0-pre1
v1.41.1
v1.41.0
v1.41.0-pre2
v1.41.0-pre1
v1.40.0
v1.40.0-pre1
v1.39.1
v1.39.0
v1.39.0-pre1
v1.38.1
v1.38.0
v1.38.0-pre1
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/grpcpp/impl/codegen/method_handler.h
+9
-3
include/grpcpp/impl/codegen/method_handler.h
src/cpp/server/server_cc.cc
+15
-4
src/cpp/server/server_cc.cc
with
24 additions
and
7 deletions
+24
-7
include/grpcpp/impl/codegen/method_handler.h
+
9
-
3
View file @
edf500fb
...
...
@@ -357,9 +357,12 @@ class SplitServerStreamingHandler
template
<::
grpc
::
StatusCode
code
>
class
ErrorMethodHandler
:
public
::
grpc
::
internal
::
MethodHandler
{
public:
explicit
ErrorMethodHandler
(
const
std
::
string
&
message
)
:
message_
(
message
)
{}
template
<
class
T
>
static
void
FillOps
(
::
grpc
::
ServerContextBase
*
context
,
T
*
ops
)
{
::
grpc
::
Status
status
(
code
,
""
);
static
void
FillOps
(
::
grpc
::
ServerContextBase
*
context
,
const
std
::
string
&
message
,
T
*
ops
)
{
::
grpc
::
Status
status
(
code
,
message
);
if
(
!
context
->
sent_initial_metadata_
)
{
ops
->
SendInitialMetadata
(
&
context
->
initial_metadata_
,
context
->
initial_metadata_flags
());
...
...
@@ -375,7 +378,7 @@ class ErrorMethodHandler : public ::grpc::internal::MethodHandler {
::
grpc
::
internal
::
CallOpSet
<::
grpc
::
internal
::
CallOpSendInitialMetadata
,
::
grpc
::
internal
::
CallOpServerSendStatus
>
ops
;
FillOps
(
param
.
server_context
,
&
ops
);
FillOps
(
param
.
server_context
,
message_
,
&
ops
);
param
.
call
->
PerformOps
(
&
ops
);
param
.
call
->
cq
()
->
Pluck
(
&
ops
);
}
...
...
@@ -388,6 +391,9 @@ class ErrorMethodHandler : public ::grpc::internal::MethodHandler {
}
return
nullptr
;
}
private:
const
std
::
string
message_
;
};
typedef
ErrorMethodHandler
<::
grpc
::
StatusCode
::
UNIMPLEMENTED
>
...
...
This diff is collapsed.
Click to expand it.
src/cpp/server/server_cc.cc
+
15
-
4
View file @
edf500fb
...
...
@@ -67,6 +67,15 @@ namespace {
// max-threads set) to the server builder.
#define DEFAULT_MAX_SYNC_SERVER_THREADS INT_MAX
// Give a useful status error message if the resource is exhausted specifically
// because the server threadpool is full.
const
char
*
kServerThreadpoolExhausted
=
"Server Threadpool Exhausted"
;
// Although we might like to give a useful status error message on unimplemented
// RPCs, it's not always possible since that also would need to be added across
// languages and isn't actually required by the spec.
const
char
*
kUnknownRpcMethod
=
""
;
class
DefaultGlobalCallbacks
final
:
public
Server
::
GlobalCallbacks
{
public:
~
DefaultGlobalCallbacks
()
override
{}
...
...
@@ -802,7 +811,7 @@ class Server::SyncRequestThreadManager : public grpc::ThreadManager {
if
(
has_sync_method_
)
{
unknown_method_
=
absl
::
make_unique
<
grpc
::
internal
::
RpcServiceMethod
>
(
"unknown"
,
grpc
::
internal
::
RpcMethod
::
BIDI_STREAMING
,
new
grpc
::
internal
::
UnknownMethodHandler
);
new
grpc
::
internal
::
UnknownMethodHandler
(
kUnknownRpcMethod
)
);
server_
->
server
()
->
core_server
->
SetBatchMethodAllocator
(
server_cq_
->
cq
(),
[
this
]
{
grpc_core
::
Server
::
BatchCallAllocation
result
;
...
...
@@ -1194,7 +1203,8 @@ void Server::Start(grpc::ServerCompletionQueue** cqs, size_t num_cqs) {
// to deal with the case of thread exhaustion
if
(
sync_server_cqs_
!=
nullptr
&&
!
sync_server_cqs_
->
empty
())
{
resource_exhausted_handler_
=
absl
::
make_unique
<
grpc
::
internal
::
ResourceExhaustedHandler
>
();
absl
::
make_unique
<
grpc
::
internal
::
ResourceExhaustedHandler
>
(
kServerThreadpoolExhausted
);
}
for
(
const
auto
&
value
:
sync_req_mgrs_
)
{
...
...
@@ -1321,8 +1331,9 @@ bool Server::UnimplementedAsyncRequest::FinalizeResult(void** tag,
Server
::
UnimplementedAsyncResponse
::
UnimplementedAsyncResponse
(
UnimplementedAsyncRequest
*
request
)
:
request_
(
request
)
{
grpc
::
Status
status
(
grpc
::
StatusCode
::
UNIMPLEMENTED
,
""
);
grpc
::
internal
::
UnknownMethodHandler
::
FillOps
(
request_
->
context
(),
this
);
grpc
::
Status
status
(
grpc
::
StatusCode
::
UNIMPLEMENTED
,
kUnknownRpcMethod
);
grpc
::
internal
::
UnknownMethodHandler
::
FillOps
(
request_
->
context
(),
kUnknownRpcMethod
,
this
);
request_
->
stream
()
->
call_
.
PerformOps
(
this
);
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Snippets