diff --git a/Cargo.lock b/Cargo.lock index 25555c82eba2f..7cb51ae8e895b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2897,7 +2897,7 @@ dependencies = [ "futures-core", "prost 0.13.1", "prost-types 0.13.1", - "tonic 0.12.1", + "tonic 0.12.2", "tracing-core", ] @@ -2921,7 +2921,7 @@ dependencies = [ "thread_local", "tokio", "tokio-stream 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "tonic 0.12.1", + "tonic 0.12.2", "tracing", "tracing-core", "tracing-subscriber", @@ -4513,7 +4513,7 @@ dependencies = [ "prost 0.13.1", "tokio", "tokio-stream 0.1.15 (registry+https://github.com/rust-lang/crates.io-index)", - "tonic 0.12.1", + "tonic 0.12.2", "tonic-build", "tower", "tower-service", @@ -5464,7 +5464,7 @@ dependencies = [ "thiserror", "tokio", "tokio-retry", - "tonic 0.12.1", + "tonic 0.12.2", "tower", "tracing", ] @@ -5477,7 +5477,7 @@ checksum = "0ae8ab26ef7c7c3f7dfb9cc3982293d031d8e78c85d00ddfb704b5c35aeff7c8" dependencies = [ "prost 0.13.1", "prost-types 0.13.1", - "tonic 0.12.1", + "tonic 0.12.2", ] [[package]] @@ -6987,7 +6987,7 @@ dependencies = [ "thiserror", "tokio", "toml 0.8.12", - "tonic 0.12.1", + "tonic 0.12.2", "tracing", ] @@ -7049,7 +7049,7 @@ dependencies = [ "futures-util", "madsim", "tokio", - "tonic 0.12.1", + "tonic 0.12.2", "tower", "tracing", ] @@ -8076,7 +8076,7 @@ dependencies = [ "prost 0.13.1", "thiserror", "tokio", - "tonic 0.12.1", + "tonic 0.12.2", ] [[package]] @@ -8088,7 +8088,7 @@ dependencies = [ "opentelemetry", "opentelemetry_sdk", "prost 0.13.1", - "tonic 0.12.1", + "tonic 0.12.2", ] [[package]] @@ -8180,7 +8180,7 @@ dependencies = [ "serde", "serde_json", "tokio", - "tonic 0.12.1", + "tonic 0.12.2", "tonic-build", "tracing", ] @@ -10435,6 +10435,7 @@ version = "2.1.0-alpha" dependencies = [ "auto_impl", "bytes", + "cfg-or-panic", "clap", "darwin-libproc", "easy-ext", @@ -14471,9 +14472,9 @@ dependencies = [ [[package]] name = "tonic" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38659f4a91aba8598d27821589f5db7dddd94601e7a01b1e485a50e5484c7401" +checksum = "c6f6ba989e4b2c58ae83d862d3a3e27690b6e3ae630d0deb59f3697f32aa88ad" dependencies = [ "async-stream", "async-trait", @@ -14505,9 +14506,9 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.12.1" +version = "0.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568392c5a2bd0020723e3f387891176aabafe36fd9fcd074ad309dfa0c8eb964" +checksum = "fe4ee8877250136bd7e3d2331632810a4df4ea5e004656990d8d66d2f5ee8a67" dependencies = [ "prettyplease 0.2.15", "proc-macro2", diff --git a/src/common/metrics/Cargo.toml b/src/common/metrics/Cargo.toml index 444f69c3fca9a..d127b02045622 100644 --- a/src/common/metrics/Cargo.toml +++ b/src/common/metrics/Cargo.toml @@ -17,6 +17,7 @@ normal = ["workspace-hack"] [dependencies] auto_impl = "1" bytes = "1" +cfg-or-panic = "0.2" clap = { workspace = true } easy-ext = "1" futures = { version = "0.3", default-features = false, features = ["alloc"] } diff --git a/src/common/metrics/src/monitor/connection.rs b/src/common/metrics/src/monitor/connection.rs index 492fdf4c049a8..54fa399c3806e 100644 --- a/src/common/metrics/src/monitor/connection.rs +++ b/src/common/metrics/src/monitor/connection.rs @@ -22,6 +22,7 @@ use std::sync::LazyLock; use std::task::{Context, Poll}; use std::time::Duration; +use cfg_or_panic::cfg_or_panic; use futures::FutureExt; use http::Uri; use hyper_util::client::legacy::connect::dns::{GaiAddrs, GaiFuture, GaiResolver, Name}; @@ -591,23 +592,40 @@ impl Service for MonitoredGaiResolver { } } +#[cfg_or_panic(not(madsim))] +fn monitored_http_connector( + connection_type: impl Into, + config: TcpConfig, +) -> MonitoredConnection, MonitorNewConnectionImpl> { + let resolver = MonitoredGaiResolver::default(); + let mut http = HttpConnector::new_with_resolver(resolver); + + http.enforce_http(false); + http.set_nodelay(config.tcp_nodelay); + http.set_keepalive(config.keepalive_duration); + + monitor_connector(http, connection_type) +} + +/// Attach general configurations to the endpoint. +#[cfg_or_panic(not(madsim))] +fn configure_endpoint(endpoint: Endpoint) -> Endpoint { + // This is to mitigate https://github.com/risingwavelabs/risingwave/issues/18039. + // TODO: remove this after https://github.com/hyperium/hyper/issues/3724 gets resolved. + endpoint.http2_max_header_list_size(16 * 1024 * 1024) +} + #[easy_ext::ext(EndpointExt)] impl Endpoint { pub async fn monitored_connect( - self, + mut self, connection_type: impl Into, config: TcpConfig, ) -> Result { #[cfg(not(madsim))] { - let resolver = MonitoredGaiResolver::default(); - let mut http = HttpConnector::new_with_resolver(resolver); - - http.enforce_http(false); - http.set_nodelay(config.tcp_nodelay); - http.set_keepalive(config.keepalive_duration); - - let connector = monitor_connector(http, connection_type); + self = configure_endpoint(self); + let connector = monitored_http_connector(connection_type, config); self.connect_with_connector(connector).await } #[cfg(madsim)] @@ -618,16 +636,12 @@ impl Endpoint { #[cfg(not(madsim))] pub fn monitored_connect_lazy( - self, + mut self, connection_type: impl Into, config: TcpConfig, ) -> Channel { - let mut http = HttpConnector::new(); - http.enforce_http(false); - http.set_nodelay(config.tcp_nodelay); - http.set_keepalive(config.keepalive_duration); - - let connector = monitor_connector(http, connection_type); + self = configure_endpoint(self); + let connector = monitored_http_connector(connection_type, config); self.connect_with_connector_lazy(connector) } }