Skip to content

Commit

Permalink
fix: change more grpc sender/recv message size to ReadableSize
Browse files Browse the repository at this point in the history
  • Loading branch information
masonyc committed Oct 12, 2023
1 parent 5ae2da5 commit d4c2528
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<FlightClient> {
Expand Down
9 changes: 5 additions & 4 deletions src/common/grpc/src/channel_manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down Expand Up @@ -250,9 +251,9 @@ pub struct ChannelConfig {
pub tcp_nodelay: bool,
pub client_tls: Option<ClientTlsOption>,
// 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 {
Expand Down
4 changes: 2 additions & 2 deletions src/datanode/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,9 +328,9 @@ pub struct DatanodeOptions {
pub rpc_hostname: Option<String>,
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<MetaClientOptions>,
Expand Down
4 changes: 2 additions & 2 deletions src/datanode/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/frontend/src/service_config/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
4 changes: 2 additions & 2 deletions src/servers/src/grpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand Down

0 comments on commit d4c2528

Please sign in to comment.