Skip to main content

Module migration

Module migration 

Source
Expand description

Moving a node off LMDB and onto the file store without losing a chunk.

LMDB never returns a deleted page to the filesystem. Disk comes back exactly once, when chunks.mdb is removed whole, so a node cannot free space by deleting chunks and cannot compact its way out either (compaction needs free space equal to the live data, which is the same condition). That single fact shapes everything here.

§The two ways this could lose data, and why neither can happen

  1. A node deletes its LMDB before the chunks are safely in files. Retirement is gated on the file store already holding every key the node still claims, and on the existing retention contract: a key the node is still answerable for under a gossiped commitment vetoes the delete.
  2. Every node sheds the same chunk at once. A node only sheds when it cannot fit its own payload, and it sheds by close-group rank, furthest first. A chunk has exactly one 7th-closest and one 6th-closest holder, so it is only ever a shed candidate for two of its seven holders, and the staged rollout brings that to one.

§Three releases

Slashing is the auditor’s decision, so a node cannot protect itself from being penalised for a shed. Everyone else has to stop first, which is why this lands over three releases rather than one:

ReleasePenalise not holding a close-group chunk?MigrationConfig::retire_legacy
First: stop that one penaltynofalse
Second: migratenotrue
Third: restore ityestrue

The penalty column is not a field here. It lives once, in crate::replication::config::RELEASE_SUSPEND_CLOSE_GROUP_STORAGE_PENALTY, and both the auditors that apply it and the shedder that depends on it being withheld read that same switch. Two copies would let a node shed while its peers still penalised.

Audits keep running and keep recording throughout. What the first release withholds is narrow and deliberate: only the penalty for not holding a close-group chunk. The commitment-bound subtree audit still penalises in every release, because the whole migration turns on a node’s reduced commitment still being binding. The record those audits keep is also how we will know when the third release is safe to ship.

Structs§

CopyReport
Summary of what the copier moved during one pass.
MigrationConfig
Operator-facing controls for the migration.
MigrationContext
The network facts the driver needs, kept behind one type so the store itself stays free of any knowledge of routing or commitments.
MigrationState
The persisted migration marker.
VolumeLock
A host-wide advisory lock that serialises migrations sharing one volume.

Enums§

GroupRank
Where this node sits in a key’s admission group.
LockAttempt
The result of asking for the volume lock.
MigrationPhase
Where a node is in the migration.

Constants§

CONCURRENT_MIGRATIONS_PER_GROUP
How many nodes of one close group may be giving chunks up at the same time.
LOCK_DIR_ENV
Environment override for the directory the per-volume migration lock lives in.
MIGRATION_EVENT
Structured field marking every line the fleet gate for R3 is read from.
MIGRATION_STATE_FILE
Filename of the persisted migration marker, under the node root.
MIN_RETIRE_DELAY_HOURS
Floor on MigrationConfig::retire_delay_hours.
RELEASE_RETIRE_LEGACY
Whether this build deletes the legacy environment once the gate is satisfied.
REQUIRED_REBUILDS_BEFORE_RETIRE
How many commitment rebuilds must be observed after the node commits to its file-backed set before the legacy environment may be retired.
RETIRE_LEGACY_ENV
Environment override for RELEASE_RETIRE_LEGACY, for a canary node.
SHEDDABLE_TAIL_RANKS
How many positions from the end of the admission group a node may give up.

Functions§

log_migration_complete
Log the operator-facing summary of a completed migration.
migration_wave_count
How many waves a close group is divided into, so that at most CONCURRENT_MIGRATIONS_PER_GROUP of it are giving chunks up at once.
migration_wave_for
Which wave this node belongs to, derived from its own ID.
now_unix
Seconds since the Unix epoch, saturating at zero if the clock is before it.
rank_closest_first
Order keys closest-first by XOR distance from this node.
rank_is_sheddable
Whether a position in the admission group may be given up.
run
Runs the migration to completion, then returns.
should_migrate
Whether this store needs a migration driver at all.
state_path
Path of the persisted marker.
unconfirmed_by_neighbours
Which of keys this node has no proof anyone else is holding.
wave_has_opened
Whether this node’s wave has opened yet.
wave_opens_at
When a given wave opens, in Unix seconds.