mon: Let any EC position lead a PG with sticky_primaries #213
@@ -192,6 +192,10 @@ primary candidates, and give a PG that needs a new primary (because its
|
||||
primary failed or left the PG) to the candidate which is primary for the
|
||||
fewest PGs of all pools.
|
||||
|
||||
In EC pools every OSD of the PG is a candidate, parity ones included, so
|
||||
hosts that come last in OSD sets lead PGs too. A parity primary reads all
|
||||
data from other OSDs.
|
||||
|
||||
By default primaries are picked by PG number and move back as soon as their
|
||||
OSD returns. Every such move restarts the PG on both OSDs, and picking by PG
|
||||
number may leave some OSDs primary for several times more PGs than others.
|
||||
|
||||
@@ -195,6 +195,10 @@ OSD перед обновлением агрегированной статис
|
||||
(потому что прежний отказал или вышел из PG), отдавать тому кандидату, который
|
||||
является первичным для наименьшего числа PG всех пулов.
|
||||
|
||||
В пулах EC кандидаты — все OSD PG, включая OSD чётности, поэтому узлы,
|
||||
стоящие последними в наборах OSD, тоже становятся первичными. Первичный OSD
|
||||
чётности читает все данные с других OSD.
|
||||
|
||||
По умолчанию первичные OSD выбираются по номеру PG и возвращаются обратно, как
|
||||
только их OSD снова включается. Каждый такой перенос перезапускает PG на обоих
|
||||
OSD, а выбор по номеру PG может сделать часть OSD первичными для в несколько
|
||||
|
||||
@@ -187,6 +187,10 @@
|
||||
primary failed or left the PG) to the candidate which is primary for the
|
||||
fewest PGs of all pools.
|
||||
|
||||
In EC pools every OSD of the PG is a candidate, parity ones included, so
|
||||
hosts that come last in OSD sets lead PGs too. A parity primary reads all
|
||||
data from other OSDs.
|
||||
|
||||
By default primaries are picked by PG number and move back as soon as their
|
||||
OSD returns. Every such move restarts the PG on both OSDs, and picking by PG
|
||||
number may leave some OSDs primary for several times more PGs than others.
|
||||
@@ -198,6 +202,10 @@
|
||||
(потому что прежний отказал или вышел из PG), отдавать тому кандидату, который
|
||||
является первичным для наименьшего числа PG всех пулов.
|
||||
|
||||
В пулах EC кандидаты — все OSD PG, включая OSD чётности, поэтому узлы,
|
||||
стоящие последними в наборах OSD, тоже становятся первичными. Первичный OSD
|
||||
чётности читает все данные с других OSD.
|
||||
|
||||
По умолчанию первичные OSD выбираются по номеру PG и возвращаются обратно, как
|
||||
только их OSD снова включается. Каждый такой перенос перезапускает PG на обоих
|
||||
OSD, а выбор по номеру PG может сделать часть OSD первичными для в несколько
|
||||
|
||||
@@ -15,7 +15,8 @@ const { make_hier_tree, filter_osds_by_root_node,
|
||||
function pick_primary(pool_id, pg_num, pool_config, osd_set, up_osds, aff_osds, cur_primary = 0, counts = null, gained = null)
|
||||
{
|
||||
let alive_set;
|
||||
if (pool_config.scheme === 'replicated')
|
||||
// With counts, EC too: OSD sets in host order would leave the last parity_chunks hosts without primaries
|
||||
if (pool_config.scheme === 'replicated' || counts)
|
||||
{
|
||||
// Prefer "affinity" OSDs
|
||||
alive_set = osd_set.filter(osd_num => osd_num && aff_osds[osd_num]);
|
||||
|
||||
@@ -20,7 +20,8 @@ function up_except(down)
|
||||
}
|
||||
|
||||
// EC 4+2 over 6 hosts, one OSD of each host per PG, primaries picked from scratch
|
||||
function make_state(pg_count, global_config)
|
||||
// host_ordered: position h of every set is on host h, as optimize_change() leaves the sets
|
||||
function make_state(pg_count, global_config, host_ordered = false)
|
||||
{
|
||||
const state = {
|
||||
config: { pools: { 1: { name: 'ec', scheme: 'ec', pg_size: 6, parity_chunks: 2, pg_minsize: 4,
|
||||
@@ -31,7 +32,7 @@ function make_state(pg_count, global_config)
|
||||
{
|
||||
const osd_set = [];
|
||||
for (let h = 0; h < HOSTS; h++)
|
||||
osd_set.push(host_osds((h + pg) % HOSTS)[(Math.floor(pg / HOSTS) * 7 + h) % PER_HOST]);
|
||||
osd_set.push(host_osds(host_ordered ? h : (h + pg) % HOSTS)[(Math.floor(pg / HOSTS) * 7 + h) % PER_HOST]);
|
||||
state.pg.config.items[1][pg] = { osd_set, primary: 0 };
|
||||
}
|
||||
state.pg.config = recheck_primary(state, global_config, up_except([]), {});
|
||||
@@ -82,16 +83,9 @@ function test_host_restart()
|
||||
assert.equal(sticky.back.length, 0, 'a live primary stays when the host returns');
|
||||
}
|
||||
|
||||
// A returned host gets no primaries back until the cluster is calm, then they are evened out,
|
||||
// each OSD getting at most one new primary per pass
|
||||
function test_rebalance_when_calm()
|
||||
// Calm rebalance passes until nothing moves, each OSD getting at most one new primary per pass
|
||||
function rebalance_until_even(state, cfg, all_up)
|
||||
{
|
||||
const cfg = { sticky_primaries: true };
|
||||
const state = make_state(1024, cfg);
|
||||
const all_up = up_except([]);
|
||||
state.pg.config = recheck_primary(state, cfg, up_except(host_osds(4)), {});
|
||||
assert(!recheck_primary(state, cfg, all_up, {}), 'nothing moves back by itself');
|
||||
const empty = spread(state.pg.config, all_up);
|
||||
let passes = 0, moved = 0, cur;
|
||||
while ((cur = recheck_primary(state, cfg, all_up, {}, true)))
|
||||
{
|
||||
@@ -102,12 +96,48 @@ function test_rebalance_when_calm()
|
||||
passes++;
|
||||
assert(passes < 30, 'rebalance converges');
|
||||
}
|
||||
return { passes, moved };
|
||||
}
|
||||
|
||||
// A returned host gets no primaries back until the cluster is calm, then they are evened out,
|
||||
// each OSD getting at most one new primary per pass
|
||||
function test_rebalance_when_calm()
|
||||
{
|
||||
const cfg = { sticky_primaries: true };
|
||||
const state = make_state(1024, cfg);
|
||||
const all_up = up_except([]);
|
||||
state.pg.config = recheck_primary(state, cfg, up_except(host_osds(4)), {});
|
||||
assert(!recheck_primary(state, cfg, all_up, {}), 'nothing moves back by itself');
|
||||
const empty = spread(state.pg.config, all_up);
|
||||
const { passes, moved } = rebalance_until_even(state, cfg, all_up);
|
||||
const even = spread(state.pg.config, all_up);
|
||||
console.log(`calm rebalance: max ${empty.max} min ${empty.min} -> max ${even.max} min ${even.min}, `+
|
||||
`${moved} primaries moved in ${passes} passes`);
|
||||
assert(empty.min == 0 && even.min > 0 && even.max - even.min <= 2, 'the returned host gets primaries again');
|
||||
}
|
||||
|
||||
// OSD sets in host order: the parity hosts lead PGs too, turning the option on moves no primary
|
||||
// and the calm rebalance then gives the parity hosts their share
|
||||
function test_host_ordered_sets()
|
||||
{
|
||||
const cfg = { sticky_primaries: true };
|
||||
const all_up = up_except([]);
|
||||
const parity_osds = [ ...host_osds(HOSTS-2), ...host_osds(HOSTS-1) ];
|
||||
const fresh = spread(make_state(1024, cfg, true).pg.config, all_up);
|
||||
assert(fresh.max - fresh.min <= 1, 'primaries picked from scratch differ by at most 1 per OSD');
|
||||
const state = make_state(1024, {}, true);
|
||||
const before = count_primaries(state.pg.config);
|
||||
assert(parity_osds.every(osd => !before[osd]), 'without the option only data positions lead');
|
||||
assert(!recheck_primary(state, cfg, all_up, {}), 'turning the option on moves no primary');
|
||||
const { passes, moved } = rebalance_until_even(state, cfg, all_up);
|
||||
assert(moved < 1024 / 2, 'fewer than half of the PGs restart');
|
||||
const even = spread(state.pg.config, all_up);
|
||||
const after = count_primaries(state.pg.config);
|
||||
console.log(`host-ordered sets: from scratch max ${fresh.max} min ${fresh.min}; after the option is turned on `+
|
||||
`max ${even.max} min ${even.min}, ${moved} primaries moved in ${passes} passes`);
|
||||
assert(parity_osds.every(osd => after[osd] > 0) && even.max - even.min <= 2, 'parity hosts get primaries');
|
||||
}
|
||||
|
||||
// New OSD sets only move the primaries that left the set
|
||||
function test_new_sets_keep_primaries()
|
||||
{
|
||||
@@ -145,6 +175,7 @@ const log = console.log;
|
||||
console.log = (s) => /^Moving pool/.exec(s) || log(s);
|
||||
test_host_restart();
|
||||
test_rebalance_when_calm();
|
||||
test_host_ordered_sets();
|
||||
test_new_sets_keep_primaries();
|
||||
test_counts_on_pg_count_change();
|
||||
console.log('OK');
|
||||
|
||||
Reference in New Issue
Block a user