Struct Timing
pub struct Timing {
pub heartbeat_ms: u64,
pub election_ms: u64,
}Expand description
Failure detection, in milliseconds of each member’s monotonic clock.
An idle primary sends a heartbeat every heartbeat_ms. A backup that
hears nothing from its primary for election_ms, plus a jitter drawn
again for every election from 0..election_ms, starts a view change, so
the loss of a primary is noticed within one to two election timeouts.
Fields§
§heartbeat_ms: u64§election_ms: u64Implementations§
§impl Timing
impl Timing
pub fn validate(&self) -> Result<(), &'static str>
pub fn validate(&self) -> Result<(), &'static str>
A heartbeat of at least 1 ms and an election timeout of at least four heartbeats, so a backup can miss a few before it suspects the primary.
pub fn promise_ms(&self) -> u64
pub fn promise_ms(&self) -> u64
How long a backup promises, after each ping from its primary, not to take part in a view change: half the election timeout, so an election that times out normally never breaks a promise.
pub fn lease_ms(&self) -> u64
pub fn lease_ms(&self) -> u64
How long after it sent a ping that a quorum answered the primary may
serve reads from its own state. The promise as the slowest allowed
backup clock measures it, as the fastest allowed primary clock
measures it, less a millisecond at each end for clock granularity:
(P - 1)(1 - ρ)/(1 + ρ) - 1 with ρ = MAX_CLOCK_DRIFT_PPM.
pub fn step_down_ms(&self) -> u64
pub fn step_down_ms(&self) -> u64
How long a primary that hears from no quorum keeps its role: four election timeouts, and at least 200 ms. A backup that is merely slow (a stalled flush, a starting process) answers late; one that lost this primary has elected another long before.