Skip to main content

Module replicated

Module replicated 

Expand description

replicated durability: the log replicated to a quorum.

Three (or five) processes each run a ReplicaNode. The replication protocol is fusee_core::vsr; one protocol entry is one log-format-3 batch carrying a section from every shard of the primary’s engine ([log3]), so one group serves all of the primary’s shards. The primary’s engine stores its log through ReplicatedEnv: a flush completes when the entry commits, that is once any quorum holds it durably, usually one round trip after it was sent; the primary’s own write runs in the background ([writes]). The engine of a backup that becomes primary recovers from the committed entries themselves: they are the only copy of the log on disk.

One I/O thread per member reads the peer sockets, runs the protocol and owns the protocol log. Shards hand it their sections and spin, then park, until it publishes their committed position; it spins, then parks, for the next section. Inbound frames are handled on the reading task itself, and every round sends at most one write per peer.

Each replica keeps:

  • vsr/log: checksummed protocol entries (appended and flushed in groups; replaced atomically by write, flush, rename);
  • vsr/superblock: view, last normal view, commit and applied hints, saved only after the log it vouches for is durable;
  • engine/: the engine’s run stores and checkpoints, one directory per shard.

A dedicated server’s group is a segment group: one shard, flush batches in log format 2, materialized into engine/shard-000/log, which its remote workers read. Fixed membership. Durable checkpoint images anchor a trimmed protocol log and let lagging replicas install a new baseline.

Structs§

NodeStatus
A replica’s role and progress. Status receivers are notified when view, primary, ready or stopped changes; the progress fields are updated in place on every commit without waking anyone, so read them by polling.
ReadGuard
Checks that reads of a replicated engine are served under a lease (see ReplicaNode::lease_valid).
ReplicaConfig
ReplicaNode
One replica of a shard group.
ReplicaObserver
Observe protocol progress and successful TCP application bytes on this member. Byte counts include frame headers, retransmissions and heartbeats.
ReplicatedEnv
The primary engine’s storage: the local engine directory for the run store and checkpoints; the replication group for the log.
StageDistribution
Cumulative nanoseconds and exact bucket counts. Subtract consecutive observations to measure one trial on a single member.

Functions§

parse_members
Parses a member list: host:port,... (IDs are positions) or id=host:port,.... Returns addresses indexed by ID (empty: no member).
stage_summary
What one member’s stages took between two snapshots: for each stage that ran, its count, mean and bucket bounds of p50 and p99 in microseconds (the true value is at most the bound, above the previous bucket’s), as JSON. A count stage (*_count_us) reports counts instead of microseconds.