diff --git a/src/client/src/client.rs b/src/client/src/client.rs index c5457e58741f..2055d40b5e0c 100644 --- a/src/client/src/client.rs +++ b/src/client/src/client.rs @@ -139,11 +139,11 @@ impl Client { } fn max_grpc_recv_message_size(&self) -> usize { - self.inner.channel_manager.config().max_recv_message_size + self.inner.channel_manager.config().max_recv_message_size.as_bytes() as usize } fn max_grpc_send_message_size(&self) -> usize { - self.inner.channel_manager.config().max_send_message_size + self.inner.channel_manager.config().max_send_message_size.as_bytes() as usize } pub(crate) fn make_flight_client(&self) -> Result { diff --git a/src/common/grpc/src/channel_manager.rs b/src/common/grpc/src/channel_manager.rs index d1e372b677c9..98451f13eee7 100644 --- a/src/common/grpc/src/channel_manager.rs +++ b/src/common/grpc/src/channel_manager.rs @@ -16,6 +16,7 @@ use std::sync::atomic::{AtomicBool, AtomicU64, AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Duration; +use common_base::readable_size::ReadableSize; use common_telemetry::info; use dashmap::mapref::entry::Entry; use dashmap::DashMap; @@ -31,8 +32,8 @@ use crate::error::{CreateChannelSnafu, InvalidConfigFilePathSnafu, InvalidTlsCon const RECYCLE_CHANNEL_INTERVAL_SECS: u64 = 60; pub const DEFAULT_GRPC_REQUEST_TIMEOUT_SECS: u64 = 10; pub const DEFAULT_GRPC_CONNECT_TIMEOUT_SECS: u64 = 1; -pub const DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE: usize = 512 * 1024 * 1024; -pub const DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE: usize = 512 * 1024 * 1024; +pub const DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE: ReadableSize = ReadableSize::mb(512); +pub const DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE: ReadableSize = ReadableSize::mb(512); lazy_static! { static ref ID: AtomicU64 = AtomicU64::new(0); @@ -250,9 +251,9 @@ pub struct ChannelConfig { pub tcp_nodelay: bool, pub client_tls: Option, // Max gRPC receiving(decoding) message size - pub max_recv_message_size: usize, + pub max_recv_message_size: ReadableSize, // Max gRPC sending(encoding) message size - pub max_send_message_size: usize, + pub max_send_message_size: ReadableSize, } impl Default for ChannelConfig { diff --git a/src/datanode/src/config.rs b/src/datanode/src/config.rs index 74c86c5ced53..0b1da56c89a9 100644 --- a/src/datanode/src/config.rs +++ b/src/datanode/src/config.rs @@ -328,9 +328,9 @@ pub struct DatanodeOptions { pub rpc_hostname: Option, pub rpc_runtime_size: usize, // Max gRPC receiving(decoding) message size - pub rpc_max_recv_message_size: usize, + pub rpc_max_recv_message_size: ReadableSize, // Max gRPC sending(encoding) message size - pub rpc_max_send_message_size: usize, + pub rpc_max_send_message_size: ReadableSize, pub heartbeat: HeartbeatOptions, pub http: HttpOptions, pub meta_client: Option, diff --git a/src/datanode/src/server.rs b/src/datanode/src/server.rs index 1847dc4c992a..ad198af81350 100644 --- a/src/datanode/src/server.rs +++ b/src/datanode/src/server.rs @@ -40,8 +40,8 @@ impl Services { let region_server_handler = Some(Arc::new(region_server.clone()) as _); let runtime = region_server.runtime(); let grpc_config = GrpcServerConfig { - max_recv_message_size: opts.rpc_max_recv_message_size, - max_send_message_size: opts.rpc_max_send_message_size, + max_recv_message_size: opts.rpc_max_recv_message_size.as_bytes() as usize, + max_send_message_size: opts.rpc_max_send_message_size.as_bytes() as usize, }; Ok(Self { diff --git a/src/frontend/src/service_config/grpc.rs b/src/frontend/src/service_config/grpc.rs index e38d6e2a74d1..899a22d3ebf3 100644 --- a/src/frontend/src/service_config/grpc.rs +++ b/src/frontend/src/service_config/grpc.rs @@ -33,8 +33,8 @@ impl Default for GrpcOptions { Self { addr: "127.0.0.1:4001".to_string(), runtime_size: 8, - max_recv_message_size: ReadableSize(DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE as u64), - max_send_message_size: ReadableSize(DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE as u64), + max_recv_message_size: DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE, + max_send_message_size: DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE, } } } diff --git a/src/servers/src/grpc.rs b/src/servers/src/grpc.rs index 69ea1943a6fa..f87fd7737dca 100644 --- a/src/servers/src/grpc.rs +++ b/src/servers/src/grpc.rs @@ -93,8 +93,8 @@ pub struct GrpcServerConfig { impl Default for GrpcServerConfig { fn default() -> Self { Self { - max_recv_message_size: DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE, - max_send_message_size: DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE, + max_recv_message_size: DEFAULT_MAX_GRPC_RECV_MESSAGE_SIZE.as_bytes() as usize, + max_send_message_size: DEFAULT_MAX_GRPC_SEND_MESSAGE_SIZE.as_bytes() as usize, } } }