Expand description
Leading: one master per database (see archive/PROJECT.md, Components and roles: production path).
A master takes the database’s lease before it starts (a second one waits as a standby),
renews it every third of Leadership::period, and leads only while its last renewal is
recent enough by its own monotonic clock: a renewal begun at t makes it lead until
t + period − query limit, before the lease itself can expire by the database’s clock (it
was set at or after t), so a master cut off from the database pauses before another can
take over.
What rules out two masters writing at once is the database itself: the master writes
through Leadership::fenced_db, whose every write checks the lease in its own
transaction (see schedr_db::Database::fenced), and is refused once another master took it
over, however late it arrives.
A renewal that finds the lease no longer its own (another holder, or the takeover counter moved on) means another master led meanwhile: this one’s view is stale and it must end. A renewal never takes the lease back.
Structs§
- Leadership
- This master’s hold on the lease.
Enums§
- Renewal
- What a renewal found.
Constants§
- DEFAULT_
LEASE_ PERIOD - The default lease period (
lease_period).