Malachi. Cluster. AutoRebalancer
(malachi v0.22.7)
View Source
Level-triggered automatic rebalancing (opt-in). A periodic reconcile that, on the lease holder,
commits the current rebalancing plan once it has stayed the same for stabilization consecutive
ticks, so a transient SWIM membership flap (a node briefly suspected, then alive again) never
triggers a vnode move. This is the k8s-controller pattern: SWIM does the fast, event-driven detection;
the decision to move vnodes reconciles desired-vs-actual and converges.
It is policy on top of the Malachi.Cluster.RebalanceCoordinator mechanism (which stays
manual-by-default): the seams :plan_fun / :commit_fun / :leader? wire to the coordinator and the
lease holder, so the timing logic is testable by driving one reconcile with the timer out of the way.
Off by default: nothing moves unless it is enabled and this node holds the lease.
Options
:plan_fun-(-> [Rebalance.change()]), the current plan (wired toRebalanceCoordinator.plan/1):commit_fun-(-> commit_result), commit under the lease (wired toRebalanceCoordinator.commit/1):leader?-(-> boolean()), whether this node holds the lease (only the leader drives):interval- ms between reconciles (default 30_000):stabilization- consecutive identical, non-empty plans required before committing (default 3):on_result-(commit_result -> any), called with each commit result (default: logs):name- optional registered name
The tick, the validated interval and the rule that an unknown message is counted and survived rather
than fatal all come from Malachi.Cluster.PeriodicWorker.
Summary
Functions
Returns a specification to start this module under a supervisor.
Runs one reconcile immediately (bypasses the timer). Useful in tests and to force a check.
Functions
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec reconcile_now(GenServer.server()) :: {plan :: list(), stable_count :: non_neg_integer()}
Runs one reconcile immediately (bypasses the timer). Useful in tests and to force a check.
@spec start_link(keyword()) :: GenServer.on_start()