The load balancer: the cluster moves work by itself
DEFINE BALANCER declares a load pass on the balancing round's own cadence: above a margin inside a window the pass sheds a placement to an idle voter, and draining a node re-places what it led — no balance statement, no coordinator, the catalog is the authority.
A cluster can watch its own load and re-home work without an operator acting and without anything standing beside the database. The balancer is a catalog row, declared like everything else the cluster knows; the pass runs on the balancing round's own cadence, with the same authority and the same logging.
Splitting and leadership moves arrived long ago — a table's shards change while
it serves, and ALTER REPLICA … LEADS moves a placement by hand. What the
balancer adds is the trigger: until now the only load-blind part was that a
move waited for a person. From 0.50.0 the trigger is measured load.
Declaring the pass
DEFINE BALANCER LOAD ABOVE 1.5 WITHIN 10s SPACING 1s;
INFO FOR NODE;
DROP BALANCER;
LOAD ABOVE 1.5 names the margin: this node's own load, measured against its
voters', running above 1.5× inside the WITHIN window asks for an act. The
pass sheds one placement — a range this node leads — onto an idle voter,
never twice within SPACING, and never the whole range at once: a move that
would overshoot is declined, on the rule that work moved whole onto an idle
node flaps back one spacing apart. A margin at or below 1, a spacing shorter
than the lease, or a window shorter than the cadence is refused at the declare,
a checked set the way DEFINE FAILOVER keeps one.
The figures behind the act are the ones a committer can verify: the node's own resource readings and its voters', heard over the peer link and labelled by age, and the leadership rows the log recorded. Nothing the balancer consumes is a claim only the balancer can see.
Draining a node re-places what it led
ALTER REPLICA warsaw ROLES NONE;
Draining is a role state on the member row, and a drained node's placements do
not wait for a failover. The pass's drain branch moves what the node led onto
the survivors — a store leader's shard lands on an idle voter with no
BALANCE LEADERSHIPS anywhere in the run, measured before the spelling
shipped: two runs out of two, the move logged and the taker serving writes.
Everything else on the row stands: the address, the identity, the
subscription. The node is a member that leads nothing; putting it back is the
same statement with its roles named again.
Watching it
INFO FOR NODE answers the declared policy under cluster.balancer — the
margin in hundredths (a reader divides by a hundred rather than the report
guessing a float), the window and the spacing, and the row's epoch and
version. /metrics carries tessari_balancer_load_moves_total beside the
existing balancer_moves_total, so a dashboard can tell a load-driven move
from a count-balancing one. The web console's cluster section renders the row
where the topology reads.
The balancer composes with the bounds the cluster already keeps: the
anti-flapping discipline of MIN/MAX SHARDS and the spacing clock are the
balancer's own, and a refused act is logged at warn with its reason, the way
every act on the round is.