osd: Yield between peering calcs started from continue_pg() too #200

Merged
vitalif merged 1 commits from koolkhel/vitastor:osd-peering-yield-repeer into master 2026-11-29 13:52:22 +03:00
Contributor

Description

Follow-up to #197. Only handle_peers() arms the 1 ms yield timer, but continue_pg_peering() also runs from continue_pg() (src/osd/osd_peering.cpp:840): after a lock reply, and through report_pg_state() -> relock_pg() (src/osd/osd_peering.cpp:813) every time a PG starts peering. start_pg_peering() keeps the lists of the peers that stay in the PG (src/osd/osd_peering.cpp:297), so a re-peered PG that was waiting for its calc has all its lists at once and is calculated right inside start_pg_peering().

So when the /osd/state of a connected peer disappears, on_change_osd_state_hook() -> repeer_pgs() calculates every PG that has that peer and waits for its calc, back to back in one pass. With #197 a PG can wait for its calc for several calcs of other PGs, so the window is seconds long on an OSD that is primary for many large PGs.

The change: arm the timer in continue_pg_peering() right after the calc, and skip the calc while the timer is armed. handle_peers() takes the PG when the timer fires (OSD_PEERING_PGS stays set while a PG is peering).

Independent of #199, which sends the queued replies before a calc in osd_t::loop(): different code, no conflict.

Found: by reading the code, then reproduced in osd_test; not seen in a run.

Tested:

  • test_peering_yields_after_repeer (osd_test): two PGs have their lists, the first is calculated, then repeer_pgs() for the peer must leave the second peering until the timer fires. It fails on master: the re-peer calculates it at once.
  • osd_test and test_pg_chaos (100 seeds) pass.

Contributor Name

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

CLA

### Description Follow-up to #197. Only `handle_peers()` arms the 1 ms yield timer, but `continue_pg_peering()` also runs from `continue_pg()` (src/osd/osd_peering.cpp:840): after a lock reply, and through `report_pg_state()` -> `relock_pg()` (src/osd/osd_peering.cpp:813) every time a PG starts peering. `start_pg_peering()` keeps the lists of the peers that stay in the PG (src/osd/osd_peering.cpp:297), so a re-peered PG that was waiting for its calc has all its lists at once and is calculated right inside `start_pg_peering()`. So when the /osd/state of a connected peer disappears, `on_change_osd_state_hook()` -> `repeer_pgs()` calculates every PG that has that peer and waits for its calc, back to back in one pass. With #197 a PG can wait for its calc for several calcs of other PGs, so the window is seconds long on an OSD that is primary for many large PGs. The change: arm the timer in `continue_pg_peering()` right after the calc, and skip the calc while the timer is armed. `handle_peers()` takes the PG when the timer fires (`OSD_PEERING_PGS` stays set while a PG is peering). Independent of #199, which sends the queued replies before a calc in `osd_t::loop()`: different code, no conflict. Found: by reading the code, then reproduced in osd_test; not seen in a run. Tested: - test_peering_yields_after_repeer (osd_test): two PGs have their lists, the first is calculated, then `repeer_pgs()` for the peer must leave the second peering until the timer fires. It fails on master: the re-peer calculates it at once. - osd_test and test_pg_chaos (100 seeds) pass. ### 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-28 14:23:33 +03:00
Only handle_peers() armed the yield timer. continue_pg_peering() also
runs from continue_pg(), and a re-peer keeps the lists of the peers
that stay, so a PG waiting for its calc gets calculated at once: when
the /osd/state of a connected peer disappears, repeer_pgs() calculates
every such PG back to back in one pass.

Arm the timer in continue_pg_peering() and skip the calc while it is
armed; handle_peers() takes the PG when the timer fires.
vitalif merged commit c3a4398792 into master 2026-11-29 13:52:22 +03:00
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#200
No description provided.