mon: Add sticky_primaries to keep live primaries and balance new ones #198
Reference in New Issue
Block a user
No description provided.
Delete Branch "koolkhel/vitastor:mon-primary-spread"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Description
The monitor picks the primary OSD of a PG as
alive_set[pg_num % alive_set.length](pick_primary()in mon/pg_gen.js) and re-picks it on every OSD up/down. Two consequences:This adds
sticky_primaries, off by default; without it nothing changes.recheck_primary()keeps its own,apply_pool_pgs()passes one object to everysave_new_pgs_txn()call of a change, and a pool whose PG count changes or which is deleted gives its primaries back first.primary_rebalance_time, 300 s by default, 0 disables): when all PGs stay clean and no OSD goes up or down for that long, a live primary moves to the least loaded candidate of its PG if it has at least 2 primaries more. One pass gives each OSD at most one new primary, so a returned OSD does not re-peer a batch of PGs at once; the next pass waits until the cluster is calm again. A monitor that becomes master also waits the full time before its first pass, and an OSD going up or down or the option set to 0 after the timer fired cancels the pass. This also evens out a running cluster after the option is enabled.Models with this branch (
recheck_primary(),save_new_pgs_txn(), andgenerate_pool_pgs()with lp_solve for the reweight; equal OSD sizes):sticky_primariesThe move counts above are without the calm-time passes. In the test layout (6 x 16 OSDs, EC 4+2, 1024 PGs) a host that failed and returned holds no primaries (max 15 / min 0); the calm-time passes bring it to max 12 / min 10 with 228 moves over 11 passes, about an hour at the default 300 s.
Related: #197 lets the event loop run between peering calculations, #180 shortens one calculation; this one lowers how many of them a single OSD gets.
Found: seen in a run. On a cluster with EC 8+2, 2048 PGs over 576 OSDs and about 850k objects per PG, a weight change made OSDs primary for up to 11 re-peering PGs at once. Each calculation took 1-3 s, and the series kept the OSD from answering pings, so peers dropped it and the PGs peered again.
Tested:
node mon/test-sticky-primaries.js: without the option, the old rotation and its move back; with it, an even spread from scratch, a failed host moves only its own primaries and nothing moves back when it returns, new OSD sets move only the primaries that left the set, exact counts after a PG count change and a pool deletion, and calm-time passes that give a returned host its primaries back with at most one new primary per OSD per pass (fails without that limit: one OSD gets 11 in one pass).Contributor Name
Yury Luneff (MIND Software LLC, https://mindsw.io)
CLA