Skip to content

Commit cdc621b

Browse files
authored
persist/pubsub: set unlimited decoding message size everywhere (#35934)
This PR sets the `max_decoding_message_size` for all pubsub servers and clients to `usize::MAX`, to avoid pubsub errors and resulting reconnects caused by participants not being able to decode received messages. There was already code in place to do this for a subset of the pubsub servers created (introduced in #21034), but it was (likely due to oversight) not applied to all of them, nor to clients. Note that we don't need to set `max_encoding_message_size`, as it already defaults to `usize::MAX`. ### Motivation We observed the decoding size limit to cause pubsub reconnects, which in turn tickles a connection leak. This change doesn't fix the leak yet but makes it less likely that we hit it.
1 parent 4218b69 commit cdc621b

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

src/persist-client/src/rpc.rs

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,12 @@ pub(crate) const PUBSUB_RECONNECT_BACKOFF: Config<Duration> = Config::new(
135135
"Backoff after an established connection to Persist PubSub service fails.",
136136
);
137137

138+
/// Max message size, used to configure gRPC servers and clients.
139+
///
140+
/// While `max_encoding_message_size` defaults to `usize::MAX`, `max_decoding_message_size` only
141+
/// defaults to 4MB, so we bump it to avoid protocol errors.
142+
const MAX_GRPC_MESSAGE_SIZE: usize = usize::MAX;
143+
138144
/// Top-level Trait to create a PubSubClient.
139145
///
140146
/// Returns a [PubSubClientConnection] with a [PubSubSender] for issuing RPCs to the PubSub
@@ -324,7 +330,7 @@ impl GrpcPubSubClient {
324330
.await;
325331

326332
let mut client = match client {
327-
Ok(client) => client,
333+
Ok(client) => client.max_decoding_message_size(MAX_GRPC_MESSAGE_SIZE),
328334
Err(err) => {
329335
error!("fatal error connecting to persist pubsub: {:?}", err);
330336
return;
@@ -1064,7 +1070,10 @@ impl PersistGrpcPubSubServer {
10641070
pub async fn serve(self, listen_addr: SocketAddr) -> Result<(), anyhow::Error> {
10651071
// Increase the default message decoding limit to avoid unnecessary panics
10661072
tonic::transport::Server::builder()
1067-
.add_service(ProtoPersistPubSubServer::new(self).max_decoding_message_size(usize::MAX))
1073+
.add_service(
1074+
ProtoPersistPubSubServer::new(self)
1075+
.max_decoding_message_size(MAX_GRPC_MESSAGE_SIZE),
1076+
)
10681077
.serve(listen_addr)
10691078
.await?;
10701079
Ok(())
@@ -1077,7 +1086,10 @@ impl PersistGrpcPubSubServer {
10771086
listener: tokio_stream::wrappers::TcpListenerStream,
10781087
) -> Result<(), anyhow::Error> {
10791088
tonic::transport::Server::builder()
1080-
.add_service(ProtoPersistPubSubServer::new(self))
1089+
.add_service(
1090+
ProtoPersistPubSubServer::new(self)
1091+
.max_decoding_message_size(MAX_GRPC_MESSAGE_SIZE),
1092+
)
10811093
.serve_with_incoming(listener)
10821094
.await?;
10831095
Ok(())

0 commit comments

Comments
 (0)