Skip to main content

Module coverage

Module coverage 

Source
Expand description

Token-ring coverage validation.

Operators sometimes ship configs where one or more peers’ token ranges leave a rack effectively empty, or where two peers in the same rack claim the same token point. Both shapes are silent footguns: the dispatcher will either skip the affected rack (empty continuum) or non-deterministically prefer one of the colliding peers (duplicate tokens), and the resulting routing surprises only show up under load. With the make_error fix shipped, the affected requests now surface as real NoTargets errors to clients (previously they were request-timeout hangs); this validator catches the offending configs at config-load time before they ever reach the dispatcher.

§Ring semantics and why Gap is structurally impossible

crate::cluster::vnode::dispatch uses wrap-around vnode semantics: for any non-empty continuum, the first peer owns (last.token, u32::MAX] and [0, first.token], and each subsequent peer at index i owns (prev.token, current.token]. As a consequence, every u32 token resolves to some peer whenever the rack has at least one continuum entry. There is no token configuration that leaves a hole in [0, u32::MAX] short of an entirely empty rack. The two failure modes this validator catches are therefore:

  • TokenCoverageError::EmptyRack - a (dc, rack) pair has peers but none contribute tokens, or has no peers at all.
  • TokenCoverageError::Overlap - two peers in the same rack claim the exact same token value, leaving the choice of primary peer for that point dependent on iteration order.

A Gap variant is intentionally not included: gaps are not reachable under the current Dynomite vnode model, and keeping the enum to the variants we actually emit avoids dead code.

§Examples

use dynomite::cluster::coverage::validate_token_coverage;
use dynomite::cluster::peer::{Peer, PeerEndpoint};
use dynomite::hashkit::DynToken;

let local = Peer::new(
    0,
    PeerEndpoint::tcp("h0".into(), 8101),
    "r1".into(),
    "dc1".into(),
    vec![DynToken::from_u32(0)],
    true,
    true,
    false,
);
assert!(validate_token_coverage(&[local]).is_ok());

Enums§

TokenCoverageError
Error returned by validate_token_coverage.

Functions§

validate_token_coverage
Validate that every (dc, rack) in peers produces a usable ring under crate::cluster::vnode::dispatch semantics.