mon: Do not rewrite unchanged last_clean_pgs #212

Open
koolkhel wants to merge 1 commits from koolkhel/vitastor:mon-last-clean-unchanged into master
Contributor

Description

save_last_clean() runs after every batch of PG state changes and put the whole last_clean_pgs map even when it did not change. While any PG of a pool is not active the value stays the same, so during mass peering every batch writes another copy of a map as large as /pg/config (about 177 KB for 2048 EC 8+2 PGs). Each copy stays in the etcd history until the next compaction, and its watch event makes the monitor run recheck_pgs again.

Write last_clean_pgs only when its value changes. A value written by vitastor-cli rm-osd still reaches the monitor through the watch, and the comparison is made against it.

Found: by reading the code while investigating etcd database growth during mass peering, then reproduced locally: etcd with revision auto-compaction, the monitor, 120 fake OSDs on 12 hosts, an EC 8+2 pool of 2048 PGs, then 60 batches flipping 100 PGs between peering and active. Before: 76 byte-identical writes of last_clean_pgs (92% of all bytes written), DB size 1.0 → 18.6 MB. After: no writes of it, DB size 1.0 → 3.2 MB.

Tested: node mon/test-last-clean.js (new; fails on master), node mon/test-sticky-primaries.js.

Contributor Name

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

CLA

### Description save_last_clean() runs after every batch of PG state changes and put the whole last_clean_pgs map even when it did not change. While any PG of a pool is not active the value stays the same, so during mass peering every batch writes another copy of a map as large as /pg/config (about 177 KB for 2048 EC 8+2 PGs). Each copy stays in the etcd history until the next compaction, and its watch event makes the monitor run recheck_pgs again. Write last_clean_pgs only when its value changes. A value written by `vitastor-cli rm-osd` still reaches the monitor through the watch, and the comparison is made against it. Found: by reading the code while investigating etcd database growth during mass peering, then reproduced locally: etcd with revision auto-compaction, the monitor, 120 fake OSDs on 12 hosts, an EC 8+2 pool of 2048 PGs, then 60 batches flipping 100 PGs between peering and active. Before: 76 byte-identical writes of last_clean_pgs (92% of all bytes written), DB size 1.0 → 18.6 MB. After: no writes of it, DB size 1.0 → 3.2 MB. Tested: `node mon/test-last-clean.js` (new; fails on master), `node mon/test-sticky-primaries.js`. ### 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-30 17:39:57 +03:00
save_last_clean() runs after every batch of PG state changes and put the
whole last_clean_pgs map even when it did not change. While any PG of a
pool is not active the value stays the same, so during mass peering
every batch writes another copy of a map as large as /pg/config (about
177 KB for 2048 EC 8+2 PGs). Each copy stays in the etcd history until
the next compaction, and its watch event makes the monitor run
recheck_pgs again.

Write last_clean_pgs only when its value changes.
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-last-clean-unchanged:koolkhel-mon-last-clean-unchanged
git checkout koolkhel-mon-last-clean-unchanged
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#212
No description provided.