diff --git a/src/cmd/src/frontend.rs b/src/cmd/src/frontend.rs index 2f10b722c732..38fa75a3a0ec 100644 --- a/src/cmd/src/frontend.rs +++ b/src/cmd/src/frontend.rs @@ -342,6 +342,8 @@ impl StartCommand { // Some queries are expected to take long time. let channel_config = ChannelConfig { timeout: None, + tcp_nodelay: opts.datanode.client.tcp_nodelay, + connect_timeout: Some(opts.datanode.client.connect_timeout), ..Default::default() }; let client = NodeClients::new(channel_config); diff --git a/src/cmd/tests/load_config_test.rs b/src/cmd/tests/load_config_test.rs index 7a50234431e2..bf4871e0bd5d 100644 --- a/src/cmd/tests/load_config_test.rs +++ b/src/cmd/tests/load_config_test.rs @@ -20,7 +20,7 @@ use common_config::Configurable; use common_grpc::channel_manager::{ DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE, DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE, }; -use common_telemetry::logging::{LoggingOptions, DEFAULT_OTLP_ENDPOINT}; +use common_telemetry::logging::{LoggingOptions, SlowQueryOptions, DEFAULT_OTLP_ENDPOINT}; use common_wal::config::raft_engine::RaftEngineConfig; use common_wal::config::DatanodeWalConfig; use datanode::config::{DatanodeOptions, RegionEngineConfig, StorageConfig}; @@ -159,8 +159,20 @@ fn test_load_metasrv_example_config() { level: Some("info".to_string()), otlp_endpoint: Some(DEFAULT_OTLP_ENDPOINT.to_string()), tracing_sample_ratio: Some(Default::default()), + slow_query: SlowQueryOptions { + enable: false, + threshold: Some(Duration::from_secs(10)), + sample_ratio: Some(1.0), + }, ..Default::default() }, + datanode: meta_srv::metasrv::DatanodeOptions { + client: meta_srv::metasrv::DatanodeClientOptions { + timeout: Duration::from_secs(10), + connect_timeout: Duration::from_secs(10), + tcp_nodelay: true, + }, + }, export_metrics: ExportMetricsOption { self_import: Some(Default::default()), remote_write: Some(Default::default()), diff --git a/src/meta-srv/src/metasrv.rs b/src/meta-srv/src/metasrv.rs index 5c53a1abbb80..ee02518fa35a 100644 --- a/src/meta-srv/src/metasrv.rs +++ b/src/meta-srv/src/metasrv.rs @@ -184,22 +184,26 @@ pub struct MetasrvInfo { // Options for datanode. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, Default)] pub struct DatanodeOptions { - pub client_options: DatanodeClientOptions, + pub client: DatanodeClientOptions, } // Options for datanode client. #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub struct DatanodeClientOptions { - pub timeout_millis: u64, - pub connect_timeout_millis: u64, + #[serde(with = "humantime_serde")] + pub timeout: Duration, + #[serde(with = "humantime_serde")] + pub connect_timeout: Duration, pub tcp_nodelay: bool, } impl Default for DatanodeClientOptions { fn default() -> Self { Self { - timeout_millis: channel_manager::DEFAULT_GRPC_REQUEST_TIMEOUT_SECS * 1000, - connect_timeout_millis: channel_manager::DEFAULT_GRPC_CONNECT_TIMEOUT_SECS * 1000, + timeout: Duration::from_secs(channel_manager::DEFAULT_GRPC_REQUEST_TIMEOUT_SECS), + connect_timeout: Duration::from_secs( + channel_manager::DEFAULT_GRPC_CONNECT_TIMEOUT_SECS, + ), tcp_nodelay: true, } } diff --git a/src/meta-srv/src/metasrv/builder.rs b/src/meta-srv/src/metasrv/builder.rs index 31c17bb8f2e6..781839a193a8 100644 --- a/src/meta-srv/src/metasrv/builder.rs +++ b/src/meta-srv/src/metasrv/builder.rs @@ -14,7 +14,6 @@ use std::sync::atomic::AtomicBool; use std::sync::{Arc, Mutex, RwLock}; -use std::time::Duration; use client::client_manager::NodeClients; use common_base::Plugins; @@ -250,13 +249,9 @@ impl MetasrvBuilder { let memory_region_keeper = Arc::new(MemoryRegionKeeper::default()); let node_manager = node_manager.unwrap_or_else(|| { let datanode_client_channel_config = ChannelConfig::new() - .timeout(Duration::from_millis( - options.datanode.client_options.timeout_millis, - )) - .connect_timeout(Duration::from_millis( - options.datanode.client_options.connect_timeout_millis, - )) - .tcp_nodelay(options.datanode.client_options.tcp_nodelay); + .timeout(options.datanode.client.timeout) + .connect_timeout(options.datanode.client.connect_timeout) + .tcp_nodelay(options.datanode.client.tcp_nodelay); Arc::new(NodeClients::new(datanode_client_channel_config)) }); let cache_invalidator = Arc::new(MetasrvCacheInvalidator::new(