Skip to content

Commit

Permalink
feat: configure heartbeat client timeout to 500ms
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Sep 22, 2023
1 parent 7762994 commit 234ac37
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 2 additions & 0 deletions config/datanode.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ interval_millis = 3000
[meta_client]
# Metasrv address list.
metasrv_addrs = ["127.0.0.1:3002"]
# Heartbeat timeout in milliseconds, 500 by default.
heartbeat_timeout_millis = 500
# Operation timeout in milliseconds, 3000 by default.
timeout_millis = 3000
# Connect server timeout in milliseconds, 5000 by default.
Expand Down
11 changes: 10 additions & 1 deletion src/meta-client/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub struct MetaClientBuilder {
enable_ddl: bool,
channel_manager: Option<ChannelManager>,
ddl_channel_manager: Option<ChannelManager>,
heartbeat_channel_manager: Option<ChannelManager>,
}

impl MetaClientBuilder {
Expand Down Expand Up @@ -122,6 +123,13 @@ impl MetaClientBuilder {
}
}

pub fn heartbeat_channel_manager(self, channel_manager: ChannelManager) -> Self {
Self {
heartbeat_channel_manager: Some(channel_manager),
..self
}
}

pub fn build(self) -> MetaClient {
let mut client = if let Some(mgr) = self.channel_manager {
MetaClient::with_channel_manager(self.id, mgr)
Expand All @@ -136,10 +144,11 @@ impl MetaClientBuilder {
let mgr = client.channel_manager.clone();

if self.enable_heartbeat {
let mgr = self.heartbeat_channel_manager.unwrap_or(mgr.clone());
client.heartbeat = Some(HeartbeatClient::new(
self.id,
self.role,
mgr.clone(),
mgr,
DEFAULT_ASK_LEADER_MAX_RETRY,
));
}
Expand Down
7 changes: 7 additions & 0 deletions src/meta-client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,18 @@ pub mod error;
pub struct MetaClientOptions {
pub metasrv_addrs: Vec<String>,
pub timeout_millis: u64,
#[serde(default = "default_heartbeat_timeout_millis")]
pub heartbeat_timeout_millis: u64,
#[serde(default = "default_ddl_timeout_millis")]
pub ddl_timeout_millis: u64,
pub connect_timeout_millis: u64,
pub tcp_nodelay: bool,
}

fn default_heartbeat_timeout_millis() -> u64 {
500u64
}

fn default_ddl_timeout_millis() -> u64 {
10_000u64
}
Expand All @@ -37,6 +43,7 @@ impl Default for MetaClientOptions {
Self {
metasrv_addrs: vec!["127.0.0.1:3002".to_string()],
timeout_millis: 3_000u64,
heartbeat_timeout_millis: default_heartbeat_timeout_millis(),
ddl_timeout_millis: default_ddl_timeout_millis(),
connect_timeout_millis: 5_000u64,
tcp_nodelay: true,
Expand Down

0 comments on commit 234ac37

Please sign in to comment.