Control plane and partitions
Decisions that put elections, failover and resource control in the watcher, and that split data into table groups and partitioned tables (D50, D51).
D50 and D51 each have several log entries: one for the design and one for every step that was built. They are shown under the main decision.
D51 The control plane lives in the watcher; the database keeps only a fence#
It was requested that master election, failover, transfer, backup and redundancy management be handled by the watcher, so the database can focus on core database work and the watcher decides which process gets what resources. The answers to the three design questions: elections by a watcher quorum with a fence in the database; the watcher's authority is changing roles (and, for resources, throttles and limits); resources by operating-system limits plus database throttles. Backups and copy or rebuild stay with the operator-configured commands of the watcher. This replaces where D42 and D50 put the election.
Steps that were built:
- Step C1, the fence and the control interface. A server started with
control = truestarts read-only and takes its role only from a control call carrying an epoch, a role and a lease; a state call reports epoch, role, lease and replication position. Both need an account with the newcontrolrole, which cannot read or write rows. - Step C2, the watcher quorum. Every watcher is the agent of one node and a member of a Raft group; the Raft log holds only decrees that assign a primary. A run on a Linux host with three servers and three watchers, killed with
kill -9, is recorded in the log. - Step C3, resource control. Priority order: foreground requests, replication, compaction, backup, rebuild. The database enforces what only it can (rate limits on its own background work) and exposes its load; the watcher decides the numbers.
- Step C4, the election is removed from the server. The in-server cluster code, its settings and its tests were deleted; the Raft crate stays because the watcher uses it.
- The watcher costs the data path no latency. The watcher is not in the request path. Per request the server does only two atomic loads and one clock read for the fence, and one atomic add for the latency histogram; the watcher polls and sends commands out of band.
D50 Partitions with a Raft group each: the design, built in layers#
The unit of a group is a table, not a shard (a change from the wording of the plan). A node that follows a primary and finds its copy no longer continues the primary's log throws away and refetches the whole table, so if a group owned only some shards of a table, that reset would destroy shards the node leads. The work was built in two layers.
- Layer 1, table groups, on the watcher (steps G1a to G1d). G1a: each group has its own fence, replication follower and write check. G1b: on a node with several groups, a request about a table led by another node is forwarded to that node's primary. G1c: the watcher quorum decides one primary per group, with decrees that carry the group number. G1d: three groups on real processes, with a failover test, and the throughput figures the log discusses.
- Layer 2, partitioned tables (step L2a built). A partitioned table
TwithPpartitions is thePphysical tablesT~p0toT~p(P-1);~cannot occur in a user's table name, so there is no clash, and no extra catalog record is needed because replication and restart already work by table name. Partitioned tables take and return JSON only, so no cross-partition field registry is needed. The limit is 256 partitions.