From e62e8b6bae1e85f119cce1fc5e021255352ef35a Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Wed, 10 Mar 2021 01:13:05 +0300 Subject: [PATCH] Use real pg configuration instead of the "last clean" one for generating PG history Basically fixes the bug introduced in 0.5.7 where an rebalance interrupted by the monitor could result in forgetting objects moved to the new place --- mon/mon.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/mon/mon.js b/mon/mon.js index ac5cba60..5a3a4951 100644 --- a/mon/mon.js +++ b/mon/mon.js @@ -845,13 +845,19 @@ class Mon pool_tree = pool_tree ? pool_tree.children : []; pool_tree = LPOptimizer.flatten_tree(pool_tree, levels, pool_cfg.failure_domain, 'osd'); this.filter_osds_by_tags(osd_tree, pool_tree, pool_cfg.osd_tags); - const prev_pg_hash = (this.state.history.last_clean_pgs.items||{})[pool_id] - || (this.state.config.pgs.items||{})[pool_id] || {}; - const prev_pgs = []; - for (const pg in prev_pg_hash) + // These are for the purpose of building history.osd_sets + const real_prev_pgs = []; + for (const pg in ((this.state.config.pgs.items||{})[pool_id]||{})) { - prev_pgs[pg-1] = prev_pg_hash[pg].osd_set; + real_prev_pgs[pg-1] = this.state.config.pgs.items[pool_id][pg].osd_set; } + // And these are for the purpose of minimizing data movement + let prev_pgs = []; + for (const pg in ((this.state.history.last_clean_pgs.items||{})[pool_id]||{})) + { + prev_pgs[pg-1] = this.state.history.last_clean_pgs.items[pool_id][pg].osd_set; + } + prev_pgs = JSON.parse(JSON.stringify(prev_pgs.length ? prev_pgs : real_prev_pgs)); const pg_history = []; const old_pg_count = prev_pgs.length; let optimize_result; @@ -909,7 +915,7 @@ class Mon } }); } LPOptimizer.print_change_stats(optimize_result); - this.save_new_pgs_txn(etcd_request, pool_id, up_osds, prev_pgs, optimize_result.int_pgs, pg_history); + this.save_new_pgs_txn(etcd_request, pool_id, up_osds, real_prev_pgs, optimize_result.int_pgs, pg_history); } this.state.config.pgs.hash = tree_hash; await this.save_pg_config(etcd_request);