common_meta/
distributed_time_constants.rs

1// Copyright 2023 Greptime Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15use std::time::Duration;
16
17/// Heartbeat interval time (is the basic unit of various time).
18pub const HEARTBEAT_INTERVAL_MILLIS: u64 = 3000;
19
20/// The frontend will also send heartbeats to Metasrv, sending an empty
21/// heartbeat every HEARTBEAT_INTERVAL_MILLIS * 6 seconds.
22pub const FRONTEND_HEARTBEAT_INTERVAL_MILLIS: u64 = HEARTBEAT_INTERVAL_MILLIS * 6;
23
24/// The lease seconds of a region. It's set by 3 heartbeat intervals
25/// (HEARTBEAT_INTERVAL_MILLIS × 3), plus some extra buffer (1 second).
26pub const REGION_LEASE_SECS: u64 =
27    Duration::from_millis(HEARTBEAT_INTERVAL_MILLIS * 3).as_secs() + 1;
28
29/// When creating table or region failover, a target node needs to be selected.
30/// If the node's lease has expired, the `Selector` will not select it.
31pub const DATANODE_LEASE_SECS: u64 = REGION_LEASE_SECS;
32
33pub const FLOWNODE_LEASE_SECS: u64 = DATANODE_LEASE_SECS;
34
35/// The lease seconds of metasrv leader.
36pub const META_LEASE_SECS: u64 = 5;
37
38/// In a lease, there are two opportunities for renewal.
39pub const META_KEEP_ALIVE_INTERVAL_SECS: u64 = META_LEASE_SECS / 2;
40
41/// The default mailbox round-trip timeout.
42pub const MAILBOX_RTT_SECS: u64 = 1;