From 04cdc7f71edc9a87fa5ebb836e523da3ca9b973d Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Thu, 9 Nov 2023 03:08:55 +0000 Subject: [PATCH] v1.17: adds keep-alive-interval to repair QUIC transport config (backport of #33866) (#33992) adds keep-alive-interval to repair QUIC transport config (#33866) QUIC connections may timeout due to infrequent repair requests. The commit configures keep_alive_interval and max_idle_timeout to avoid timeouts. (cherry picked from commit 3ac2507d36715579401270bbcec246cf494c6d44) Co-authored-by: behzad nouri --- core/src/repair/quic_endpoint.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/core/src/repair/quic_endpoint.rs b/core/src/repair/quic_endpoint.rs index 2c5e954a626c74..c6f2e00df53a26 100644 --- a/core/src/repair/quic_endpoint.rs +++ b/core/src/repair/quic_endpoint.rs @@ -6,8 +6,8 @@ use { log::error, quinn::{ ClientConfig, ConnectError, Connecting, Connection, ConnectionError, Endpoint, - EndpointConfig, ReadError, ReadToEndError, RecvStream, SendStream, ServerConfig, - TokioRuntime, TransportConfig, VarInt, WriteError, + EndpointConfig, IdleTimeout, ReadError, ReadToEndError, RecvStream, SendStream, + ServerConfig, TokioRuntime, TransportConfig, VarInt, WriteError, }, rcgen::RcgenError, rustls::{Certificate, PrivateKey}, @@ -46,7 +46,13 @@ const CONNECT_SERVER_NAME: &str = "solana-repair"; const CLIENT_CHANNEL_BUFFER: usize = 1 << 14; const ROUTER_CHANNEL_BUFFER: usize = 64; const CONNECTION_CACHE_CAPACITY: usize = 3072; + +// Transport config. +// Repair randomly samples peers, uses bi-directional streams and generally has +// low to moderate load and so is configured separately from other protocols. +const KEEP_ALIVE_INTERVAL: Duration = Duration::from_secs(4); const MAX_CONCURRENT_BIDI_STREAMS: VarInt = VarInt::from_u32(512); +const MAX_IDLE_TIMEOUT: Duration = Duration::from_secs(10); const CONNECTION_CLOSE_ERROR_CODE_SHUTDOWN: VarInt = VarInt::from_u32(1); const CONNECTION_CLOSE_ERROR_CODE_DROPPED: VarInt = VarInt::from_u32(2); @@ -195,11 +201,15 @@ fn new_client_config(cert: Certificate, key: PrivateKey) -> Result TransportConfig { + let max_idle_timeout = IdleTimeout::try_from(MAX_IDLE_TIMEOUT).unwrap(); let mut config = TransportConfig::default(); + // Disable datagrams and uni streams. config + .datagram_receive_buffer_size(None) + .keep_alive_interval(Some(KEEP_ALIVE_INTERVAL)) .max_concurrent_bidi_streams(MAX_CONCURRENT_BIDI_STREAMS) .max_concurrent_uni_streams(VarInt::from(0u8)) - .datagram_receive_buffer_size(None); + .max_idle_timeout(Some(max_idle_timeout)); config }