mon: Optimise from current PGs if last_clean_pgs would move more data #179

Open
koolkhel wants to merge 2 commits from koolkhel/vitastor:mon-pg-base-fewer-moves into master
Contributor

Description

last_clean_pgs is only updated when the whole pool is clean, and every re-optimisation (reweight, OSD out, pool change) starts from it. While the pool stays unclean and the current PGs drift away from last_clean_pgs, each round lands on a new layout and moves a large part of the pool again. For example, on 12 hosts x 48 OSDs, EC 8+2, 2048 PGs, with two OSDs of one host reweighted to 0 and the pool not clean afterwards, every re-optimisation with unchanged weights moves 73-76 PGs, and bringing one of the OSDs back moves 117 PGs. If the OSD IDs of a host changed after the last clean state, a single reweight moves about 1660 of 2048 PGs.

This change also optimises from the current PGs in that case and keeps the result which places fewer PG items on OSDs without their data, i.e. neither the current OSD nor one from the PG history. Ties go to last_clean_pgs, so an OSD which comes back before its PGs recover still gets the same PGs back. The second LP is only solved when last_clean_pgs differs from the current PGs with the same PG count.

Independent of #178 (that one changes mon/lp_optimizer/lp_optimizer.js, this one only mon/pg_gen.js).

Found: seen on a large cluster with 2048 PGs: after two OSDs returned from reweight 0 the monitor moved about 870 PGs, then about 880 more on every recalculation, so the data movement did not converge.

Tested: node mon/test-pg-base.js (12 hosts x 8 OSDs, 256 PGs, an EC 8+2 pool and a replicated pool with 3 copies):

  • stale last_clean_pgs, one OSD back: EC 434-485 PG items moved on master (its share is 26.7), 124-176 with the fix; replicated 28-38 on master (share 8.0), 15-20 with the fix. Both fail on master;
  • short outage, the OSD comes back before its PGs recover: 1-4 PGs differ from the last clean state, same as master (49-54 without the PG history check);
  • breaking the replicated (unordered) comparison in count_moved_osds makes the replicated case fail.

Contributor Name

Yury Luneff (MIND Software LLC, https://mindsw.io)

CLA

### Description `last_clean_pgs` is only updated when the whole pool is clean, and every re-optimisation (reweight, OSD out, pool change) starts from it. While the pool stays unclean and the current PGs drift away from `last_clean_pgs`, each round lands on a new layout and moves a large part of the pool again. For example, on 12 hosts x 48 OSDs, EC 8+2, 2048 PGs, with two OSDs of one host reweighted to 0 and the pool not clean afterwards, every re-optimisation with unchanged weights moves 73-76 PGs, and bringing one of the OSDs back moves 117 PGs. If the OSD IDs of a host changed after the last clean state, a single reweight moves about 1660 of 2048 PGs. This change also optimises from the current PGs in that case and keeps the result which places fewer PG items on OSDs without their data, i.e. neither the current OSD nor one from the PG history. Ties go to `last_clean_pgs`, so an OSD which comes back before its PGs recover still gets the same PGs back. The second LP is only solved when `last_clean_pgs` differs from the current PGs with the same PG count. Independent of #178 (that one changes `mon/lp_optimizer/lp_optimizer.js`, this one only `mon/pg_gen.js`). Found: seen on a large cluster with 2048 PGs: after two OSDs returned from reweight 0 the monitor moved about 870 PGs, then about 880 more on every recalculation, so the data movement did not converge. Tested: `node mon/test-pg-base.js` (12 hosts x 8 OSDs, 256 PGs, an EC 8+2 pool and a replicated pool with 3 copies): - stale `last_clean_pgs`, one OSD back: EC 434-485 PG items moved on master (its share is 26.7), 124-176 with the fix; replicated 28-38 on master (share 8.0), 15-20 with the fix. Both fail on master; - short outage, the OSD comes back before its PGs recover: 1-4 PGs differ from the last clean state, same as master (49-54 without the PG history check); - breaking the replicated (unordered) comparison in `count_moved_osds` makes the replicated case fail. ### Contributor Name Yury Luneff (MIND Software LLC, https://mindsw.io) ### CLA - [x] I accept Vitastor CLA agreement: https://git.yourcmc.ru/vitalif/vitastor/src/branch/master/CLA-en.md
koolkhel added 1 commit 2026-11-24 23:07:42 +03:00
last_clean_pgs is only updated when the whole pool is clean, and every
re-optimisation (reweight, OSD out, pool change) starts from it. While
the pool stays unclean and the current PGs drift away from
last_clean_pgs, each round lands on a new layout and moves a large part
of the pool again.

In that case also optimise from the current PGs and take the result
which places fewer PG items on OSDs without their data, i.e. neither
the current OSD nor one from the PG history. Ties go to last_clean_pgs,
so an OSD which comes back before its PGs recover gets the same PGs.
koolkhel added 1 commit 2026-11-25 02:43:41 +03:00
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u mon-pg-base-fewer-moves:koolkhel-mon-pg-base-fewer-moves
git checkout koolkhel-mon-pg-base-fewer-moves
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#179
No description provided.