Expand description
Multi-server operation: one active leader, any number of standbys, all on
the same PostgreSQL database (orbit server --cluster).
- Election. Every node keeps a dedicated PostgreSQL session (separate
from the store’s connection) and tries
pg_try_advisory_lockon a fixed key once per check interval. The session that holds the lock is the leader. PostgreSQL releases the lock when that session ends, so a crashed leader is replaced within about one interval. - Fencing. On election the leader increments
orbit_cluster.termand opens its store inPgMode::Fencedmode: every history append checks the term inside its own transaction. A deposed leader that has not yet noticed cannot write anything. - Liveness. The leader re-checks its session, its lock and the term every interval. It only serves while the last successful check is younger than the lease; when a check fails it steps down to standby in-process (drops its engine and its lock session) and rejoins the election.
- Standby. A standby serves read-only routes from the database through
an engine opened on a
PgMode::ReadOnlystore, and answers every write and worker route with503 NOT_LEADERand the leader’s address.
Structs§
- Cluster
Config - Node
- One cluster member. Created by the CLI, driven by
start.
Enums§
Constants§
- LEADER_
LOCK_ KEY - Advisory lock key for leader election (ASCII “orbitldr”).
Functions§
- default_
node_ id - A default node id:
$HOSTNAME,/etc/hostname, or a random id. - grpc_
gate - gRPC interceptor: on a standby every worker call fails with
UNAVAILABLEandorbit-error-code: NOT_LEADER(SDKs retry it like a connection error). - layer
- Wrap the API router: adds
/v1/ready, the cluster fields of/v1/health, and (in cluster mode) refuses writes on a standby. Runs before authentication, so load balancers can probe/v1/readywithout credentials. - start
- Start the election thread for
node, swapping engines instateas the node gains and loses leadership.statemust hold a standby engine (Node::standby_engine) to begin with.
Type Aliases§
- Engine
Factory - Builds an engine on a store. The CLI passes one that applies the server’s engine configuration and telemetry, so leader and standby engines are configured exactly like a single-node server’s.