diff --git a/src/common/meta/src/distributed_time_constants.rs b/src/common/meta/src/distributed_time_constants.rs index 4c4148f184af..2b2b84fff81a 100644 --- a/src/common/meta/src/distributed_time_constants.rs +++ b/src/common/meta/src/distributed_time_constants.rs @@ -33,5 +33,8 @@ pub const DATANODE_LEASE_SECS: u64 = REGION_LEASE_SECS; /// The lease seconds of metasrv leader. pub const META_LEASE_SECS: u64 = 3; -// In a lease, there are two opportunities for renewal. +/// In a lease, there are two opportunities for renewal. pub const META_KEEP_ALIVE_INTERVAL_SECS: u64 = META_LEASE_SECS / 2; + +/// The default mailbox round-trip timeout. +pub const MAILBOX_RTT_SECS: u64 = 1; diff --git a/src/meta-srv/src/procedure/region_migration/downgrade_leader_region.rs b/src/meta-srv/src/procedure/region_migration/downgrade_leader_region.rs index 8e1185d7ee12..69952e6953c2 100644 --- a/src/meta-srv/src/procedure/region_migration/downgrade_leader_region.rs +++ b/src/meta-srv/src/procedure/region_migration/downgrade_leader_region.rs @@ -16,7 +16,7 @@ use std::any::Any; use std::time::Duration; use api::v1::meta::MailboxMessage; -use common_meta::distributed_time_constants::REGION_LEASE_SECS; +use common_meta::distributed_time_constants::{MAILBOX_RTT_SECS, REGION_LEASE_SECS}; use common_meta::instruction::{ DowngradeRegion, DowngradeRegionReply, Instruction, InstructionReply, }; @@ -31,7 +31,7 @@ use crate::handler::HeartbeatMailbox; use crate::procedure::region_migration::{Context, State}; use crate::service::mailbox::Channel; -const DOWNGRADE_LEADER_REGION_TIMEOUT: Duration = Duration::from_secs(1); +const DOWNGRADE_LEADER_REGION_TIMEOUT: Duration = Duration::from_secs(MAILBOX_RTT_SECS); #[derive(Debug, Serialize, Deserialize)] pub struct DowngradeLeaderRegion { @@ -159,7 +159,7 @@ impl DowngradeLeaderRegion { } Err(error::Error::MailboxTimeout { .. }) => { let reason = format!( - "Mailbox received timeout for downgrade leader region {region_id} on Datanode {:?}", + "Mailbox received timeout for downgrade leader region {region_id} on datanode {:?}", leader, ); error::RetryLaterSnafu { reason }.fail() diff --git a/src/meta-srv/src/procedure/region_migration/open_candidate_region.rs b/src/meta-srv/src/procedure/region_migration/open_candidate_region.rs index 2e126625347f..496237d5b62b 100644 --- a/src/meta-srv/src/procedure/region_migration/open_candidate_region.rs +++ b/src/meta-srv/src/procedure/region_migration/open_candidate_region.rs @@ -18,6 +18,7 @@ use std::time::Duration; use api::v1::meta::MailboxMessage; use common_meta::ddl::utils::region_storage_path; +use common_meta::distributed_time_constants::MAILBOX_RTT_SECS; use common_meta::instruction::{Instruction, InstructionReply, OpenRegion, SimpleReply}; use common_meta::RegionIdent; use serde::{Deserialize, Serialize}; @@ -29,7 +30,7 @@ use crate::procedure::region_migration::downgrade_leader_region::DowngradeLeader use crate::procedure::region_migration::{Context, State}; use crate::service::mailbox::Channel; -const OPEN_CANDIDATE_REGION_TIMEOUT: Duration = Duration::from_secs(1); +const OPEN_CANDIDATE_REGION_TIMEOUT: Duration = Duration::from_secs(MAILBOX_RTT_SECS); #[derive(Debug, Serialize, Deserialize)] pub struct OpenCandidateRegion; @@ -152,7 +153,7 @@ impl OpenCandidateRegion { } else { error::RetryLaterSnafu { reason: format!( - "Region {region_id} is not opened by Datanode {:?}, error: {error:?}", + "Region {region_id} is not opened by datanode {:?}, error: {error:?}", candidate, ), } @@ -161,7 +162,7 @@ impl OpenCandidateRegion { } Err(error::Error::MailboxTimeout { .. }) => { let reason = format!( - "Mailbox received timeout for open candidate region {region_id} on Datanode {:?}", + "Mailbox received timeout for open candidate region {region_id} on datanode {:?}", candidate, ); error::RetryLaterSnafu { reason }.fail() diff --git a/src/meta-srv/src/procedure/region_migration/upgrade_candidate_region.rs b/src/meta-srv/src/procedure/region_migration/upgrade_candidate_region.rs index 4baa609a09a1..c31ae31520de 100644 --- a/src/meta-srv/src/procedure/region_migration/upgrade_candidate_region.rs +++ b/src/meta-srv/src/procedure/region_migration/upgrade_candidate_region.rs @@ -16,6 +16,7 @@ use std::any::Any; use std::time::Duration; use api::v1::meta::MailboxMessage; +use common_meta::distributed_time_constants::MAILBOX_RTT_SECS; use common_meta::instruction::{Instruction, InstructionReply, UpgradeRegion, UpgradeRegionReply}; use common_telemetry::warn; use serde::{Deserialize, Serialize}; @@ -69,7 +70,7 @@ impl State for UpgradeCandidateRegion { } impl UpgradeCandidateRegion { - const UPGRADE_CANDIDATE_REGION_RTT: Duration = Duration::from_secs(1); + const UPGRADE_CANDIDATE_REGION_RTT: Duration = Duration::from_secs(MAILBOX_RTT_SECS); /// Returns the timeout of the upgrade candidate region. /// @@ -146,7 +147,7 @@ impl UpgradeCandidateRegion { if error.is_some() { return error::RetryLaterSnafu { reason: format!( - "Failed to upgrade the region {} on Datanode {:?}, error: {:?}", + "Failed to upgrade the region {} on datanode {:?}, error: {:?}", region_id, candidate, error ), } @@ -157,7 +158,7 @@ impl UpgradeCandidateRegion { exists, error::UnexpectedSnafu { violated: format!( - "Expected region {} doesn't exist on Datanode {:?}", + "Expected region {} doesn't exist on datanode {:?}", region_id, candidate ) } @@ -166,7 +167,7 @@ impl UpgradeCandidateRegion { if self.require_ready && !ready { return error::RetryLaterSnafu { reason: format!( - "Candidate region {} still replaying the wal on Datanode {:?}", + "Candidate region {} still replaying the wal on datanode {:?}", region_id, candidate ), } @@ -177,7 +178,7 @@ impl UpgradeCandidateRegion { } Err(error::Error::MailboxTimeout { .. }) => { let reason = format!( - "Mailbox received timeout for upgrade candidate region {region_id} on Datanode {:?}", + "Mailbox received timeout for upgrade candidate region {region_id} on datanode {:?}", candidate, ); error::RetryLaterSnafu { reason }.fail()