From c112dd7054189af77760d19b9198be0236a21065 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 5 Jan 2024 09:53:58 -0800 Subject: [PATCH] [server] Make pending queue timeout configurable (#35459) Help out with b/314162143 Closes #35459 COPYBARA_INTEGRATE_REVIEW=https://github.com/grpc/grpc/pull/35459 from ctiller:config-timeout daa00917bcefab1a833145c827219a31bdce8095 PiperOrigin-RevId: 596019307 --- include/grpc/impl/channel_arg_names.h | 6 ++++++ src/core/lib/surface/server.cc | 6 +++++- src/core/lib/surface/server.h | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/include/grpc/impl/channel_arg_names.h b/include/grpc/impl/channel_arg_names.h index 534300f22c2..b42bf7026ef 100644 --- a/include/grpc/impl/channel_arg_names.h +++ b/include/grpc/impl/channel_arg_names.h @@ -106,6 +106,12 @@ */ #define GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS \ "grpc.http2.min_ping_interval_without_data_ms" +/** Maximum time to allow a request to be: + (1) received by the server, but + (2) not requested by a RequestCall (in the completion queue based API) + before the request is cancelled */ +#define GRPC_ARG_SERVER_MAX_UNREQUESTED_TIME_IN_SERVER_SECONDS \ + "grpc.server_max_unrequested_time_in_server" /** Channel arg to override the http2 :scheme header */ #define GRPC_ARG_HTTP2_SCHEME "grpc.http2_scheme" /** How many pings can the client send before needing to send a diff --git a/src/core/lib/surface/server.cc b/src/core/lib/surface/server.cc index 249dca33497..44b541a8593 100644 --- a/src/core/lib/surface/server.cc +++ b/src/core/lib/surface/server.cc @@ -829,7 +829,11 @@ RefCountedPtr CreateChannelzNode( Server::Server(const ChannelArgs& args) : channel_args_(args), channelz_node_(CreateChannelzNode(args)), - server_call_tracer_factory_(ServerCallTracerFactory::Get(args)) {} + server_call_tracer_factory_(ServerCallTracerFactory::Get(args)), + max_time_in_pending_queue_(Duration::Seconds( + channel_args_ + .GetInt(GRPC_ARG_SERVER_MAX_UNREQUESTED_TIME_IN_SERVER_SECONDS) + .value_or(30))) {} Server::~Server() { // Remove the cq pollsets from the config_fetcher. diff --git a/src/core/lib/surface/server.h b/src/core/lib/surface/server.h index 83d5bc6a8d3..11ec7c68a45 100644 --- a/src/core/lib/surface/server.h +++ b/src/core/lib/surface/server.h @@ -489,7 +489,7 @@ class Server : public InternallyRefCounted, 0, channel_args_.GetInt(GRPC_ARG_SERVER_MAX_PENDING_REQUESTS_HARD_LIMIT) .value_or(3000)))}; - Duration max_time_in_pending_queue_{Duration::Seconds(30)}; + const Duration max_time_in_pending_queue_; absl::BitGen bitgen_ ABSL_GUARDED_BY(mu_call_); std::list channels_;