From 6220e4fdf26f22cdb114e610a00d16d051cd1d08 Mon Sep 17 00:00:00 2001 From: Ahmed Farghal Date: Tue, 6 Jan 2026 11:54:00 +0000 Subject: [PATCH] Removes max_encoding_message_size from all grpc servers and clients This change is part of #4130 1. Errors in the send path caused by encoding limits cannot be surfaced in logs or handled properly - connections are silently dropped. We leave the encoding limit as unlimited (the default) and will add explicit checks in key parts of the send path in a subsequent PR. 2. Setting a high decode limit does not add overhead since tonic does not preallocate this value per decoder. It only uses it as a check to limit uncompressed buffer sizes. Decode failures due to limits are correctly surfaced in logs. Therefore, we are opting to have an unlimited encoding limit on the grpc layer since failures are obsecure and we'll selectively add explicit checks in the important parts of the send path in a subsequent PR. The decode size limit is still set so practically, the impact of this change is improved logging when the limit is hit. --- crates/admin/src/cluster_controller/grpc_svc_handler.rs | 1 - crates/core/src/network/grpc/connector.rs | 1 - crates/core/src/network/grpc/svc_handler.rs | 1 - crates/core/src/protobuf.rs | 2 -- crates/log-server-grpc/src/lib.rs | 1 - crates/log-server/src/grpc_svc_handler.rs | 1 - crates/log-server/src/protobuf.rs | 1 - crates/metadata-server-grpc/src/grpc.rs | 1 - crates/metadata-server/src/grpc/handler.rs | 1 - crates/metadata-server/src/raft/network/handler.rs | 1 - crates/metadata-store/src/protobuf.rs | 1 - crates/node/src/network_server/grpc_svc_handler.rs | 2 -- 12 files changed, 14 deletions(-) diff --git a/crates/admin/src/cluster_controller/grpc_svc_handler.rs b/crates/admin/src/cluster_controller/grpc_svc_handler.rs index 39f293eac8..2999f7b735 100644 --- a/crates/admin/src/cluster_controller/grpc_svc_handler.rs +++ b/crates/admin/src/cluster_controller/grpc_svc_handler.rs @@ -81,7 +81,6 @@ impl ClusterCtrlSvcHandler { pub fn into_server(self, config: &NetworkingOptions) -> ClusterCtrlSvcServer { let server = ClusterCtrlSvcServer::new(self) .max_decoding_message_size(config.max_message_size.as_usize()) - .max_encoding_message_size(config.max_message_size.as_usize()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); diff --git a/crates/core/src/network/grpc/connector.rs b/crates/core/src/network/grpc/connector.rs index cba4c1cf26..21dc175e94 100644 --- a/crates/core/src/network/grpc/connector.rs +++ b/crates/core/src/network/grpc/connector.rs @@ -56,7 +56,6 @@ impl TransportConnect for GrpcConnector { // Establish the connection let client = CoreNodeSvcClient::new(channel) - .max_encoding_message_size(MAX_MESSAGE_SIZE) .max_decoding_message_size(MAX_MESSAGE_SIZE) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) diff --git a/crates/core/src/network/grpc/svc_handler.rs b/crates/core/src/network/grpc/svc_handler.rs index e5c5d8adfa..846812fb10 100644 --- a/crates/core/src/network/grpc/svc_handler.rs +++ b/crates/core/src/network/grpc/svc_handler.rs @@ -37,7 +37,6 @@ impl CoreNodeSvcHandler { pub fn into_server(self, config: &NetworkingOptions) -> CoreNodeSvcServer { let server = CoreNodeSvcServer::new(self) .max_decoding_message_size(MAX_MESSAGE_SIZE) - .max_encoding_message_size(MAX_MESSAGE_SIZE) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); diff --git a/crates/core/src/protobuf.rs b/crates/core/src/protobuf.rs index 0773bda8ba..c21c4d5e11 100644 --- a/crates/core/src/protobuf.rs +++ b/crates/core/src/protobuf.rs @@ -22,7 +22,6 @@ pub mod cluster_ctrl_svc { connection_options: &O, ) -> cluster_ctrl_svc_client::ClusterCtrlSvcClient { cluster_ctrl_svc_client::ClusterCtrlSvcClient::new(channel) - .max_encoding_message_size(connection_options.max_message_size()) .max_decoding_message_size(connection_options.max_message_size()) // note: the order of those calls defines the priority .accept_compressed(tonic::codec::CompressionEncoding::Zstd) @@ -69,7 +68,6 @@ pub mod node_ctl_svc { connection_options: &O, ) -> NodeCtlSvcClient { node_ctl_svc_client::NodeCtlSvcClient::new(channel) - .max_encoding_message_size(connection_options.max_message_size()) .max_decoding_message_size(connection_options.max_message_size()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) diff --git a/crates/log-server-grpc/src/lib.rs b/crates/log-server-grpc/src/lib.rs index 4e689652ec..f25d455013 100644 --- a/crates/log-server-grpc/src/lib.rs +++ b/crates/log-server-grpc/src/lib.rs @@ -28,7 +28,6 @@ pub fn new_log_server_client( log_server_svc_client::LogServerSvcClient::new(channel) .max_decoding_message_size(MAX_MESSAGE_SIZE) - .max_encoding_message_size(MAX_MESSAGE_SIZE) // note: the order of those calls defines the priority .accept_compressed(tonic::codec::CompressionEncoding::Zstd) .accept_compressed(tonic::codec::CompressionEncoding::Gzip) diff --git a/crates/log-server/src/grpc_svc_handler.rs b/crates/log-server/src/grpc_svc_handler.rs index c9d84c8284..e7c2f4c2e9 100644 --- a/crates/log-server/src/grpc_svc_handler.rs +++ b/crates/log-server/src/grpc_svc_handler.rs @@ -43,7 +43,6 @@ where pub fn into_server(self, config: &NetworkingOptions) -> LogServerSvcServer { let server = LogServerSvcServer::new(self) .max_decoding_message_size(MAX_MESSAGE_SIZE) - .max_encoding_message_size(MAX_MESSAGE_SIZE) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); diff --git a/crates/log-server/src/protobuf.rs b/crates/log-server/src/protobuf.rs index ab93ef2b57..b178325cb4 100644 --- a/crates/log-server/src/protobuf.rs +++ b/crates/log-server/src/protobuf.rs @@ -21,7 +21,6 @@ pub fn new_log_server_client( use restate_core::network::grpc::{DEFAULT_GRPC_COMPRESSION, MAX_MESSAGE_SIZE}; log_server_svc_client::LogServerSvcClient::new(channel) .max_decoding_message_size(MAX_MESSAGE_SIZE) - .max_encoding_message_size(MAX_MESSAGE_SIZE) // note: the order of those calls defines the priority .accept_compressed(tonic::codec::CompressionEncoding::Zstd) .accept_compressed(tonic::codec::CompressionEncoding::Gzip) diff --git a/crates/metadata-server-grpc/src/grpc.rs b/crates/metadata-server-grpc/src/grpc.rs index 0881170d17..a7fc75c9c3 100644 --- a/crates/metadata-server-grpc/src/grpc.rs +++ b/crates/metadata-server-grpc/src/grpc.rs @@ -29,7 +29,6 @@ where metadata_server_svc_client::MetadataServerSvcClient::new(channel) .max_decoding_message_size(connection_options.max_message_size()) - .max_encoding_message_size(connection_options.max_message_size()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip) diff --git a/crates/metadata-server/src/grpc/handler.rs b/crates/metadata-server/src/grpc/handler.rs index de3a10fee5..4f121cdcbc 100644 --- a/crates/metadata-server/src/grpc/handler.rs +++ b/crates/metadata-server/src/grpc/handler.rs @@ -72,7 +72,6 @@ impl MetadataServerHandler { pub fn into_server(self, config: &NetworkingOptions) -> MetadataServerSvcServer { let server = MetadataServerSvcServer::new(self) .max_decoding_message_size(config.max_message_size.as_usize()) - .max_encoding_message_size(config.max_message_size.as_usize()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); diff --git a/crates/metadata-server/src/raft/network/handler.rs b/crates/metadata-server/src/raft/network/handler.rs index 336cb00e36..2873798c04 100644 --- a/crates/metadata-server/src/raft/network/handler.rs +++ b/crates/metadata-server/src/raft/network/handler.rs @@ -47,7 +47,6 @@ impl MetadataServerNetworkHandler { pub fn into_server(self, config: &NetworkingOptions) -> MetadataServerNetworkSvcServer { let server = MetadataServerNetworkSvcServer::new(self) .max_decoding_message_size(config.max_message_size.as_usize()) - .max_encoding_message_size(config.max_message_size.as_usize()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); diff --git a/crates/metadata-store/src/protobuf.rs b/crates/metadata-store/src/protobuf.rs index e58007a1bb..b536d562bb 100644 --- a/crates/metadata-store/src/protobuf.rs +++ b/crates/metadata-store/src/protobuf.rs @@ -42,7 +42,6 @@ pub mod metadata_proxy_svc { options: &O, ) -> MetadataProxySvcClient { MetadataProxySvcClient::new(connection_options) - .max_encoding_message_size(options.max_message_size()) .max_decoding_message_size(options.max_message_size()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) diff --git a/crates/node/src/network_server/grpc_svc_handler.rs b/crates/node/src/network_server/grpc_svc_handler.rs index 344a5c6058..65441c564e 100644 --- a/crates/node/src/network_server/grpc_svc_handler.rs +++ b/crates/node/src/network_server/grpc_svc_handler.rs @@ -57,7 +57,6 @@ impl NodeCtlSvcHandler { pub fn into_server(self, config: &NetworkingOptions) -> NodeCtlSvcServer { let server = NodeCtlSvcServer::new(self) .max_decoding_message_size(config.max_message_size.as_usize()) - .max_encoding_message_size(config.max_message_size.as_usize()) // note: the order of those calls defines the priority .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); @@ -276,7 +275,6 @@ impl MetadataProxySvcHandler { let server = MetadataProxySvcServer::new(self) // note: the order of those calls defines the priority .max_decoding_message_size(config.max_message_size.as_usize()) - .max_encoding_message_size(config.max_message_size.as_usize()) .accept_compressed(CompressionEncoding::Zstd) .accept_compressed(CompressionEncoding::Gzip); if config.disable_compression {