osd: Put the current OSD set into the PG history when a peering flush reports the epoch #217

Merged
vitalif merged 1 commits from koolkhel/vitastor:flush-history-cur-set into master 2026-12-02 01:36:19 +03:00
Contributor

Description

Since #131 the peering flush reports a new epoch itself, so that the holders of the versions it stabilizes are in the PG history first. The write path adds the current OSD set of a degraded PG to the history only when it reports the epoch (report_epoch(), if (pg.epoch > pg.reporting_epoch)). After a flush has reported it, the first degraded write of the same peering finds the epoch reported and skips that, so the degraded set never reaches the history.

Sequence, EC 2+1 with pg_minsize 2, immediate_commit=all: OSD 3 is down, the PG peers on {1,2} and rolls back a leftover unstable version (the flush reports epoch E). A client write goes to OSDs 1 and 2, OSD 1 stabilizes its own part and is lost before OSD 2 stabilizes. The PG peers on {2,3}: the history has {1,2,3} but not {1,2}, so it activates and rolls OSD 2's part back. OSD 1 returns with a lone stable version and the object stays incomplete. Before #131 the write's own epoch report put {1,2} into the history and the PG waited for OSD 1.

The fix reports the epoch from the flush with report_epoch(), so the current OSD set goes into the history together with the holders, as it would on the first write. The cost: a degraded PG that flushed something but got no write in that peering now also waits for its last OSD set at the next peering, the same as after any single write.

Reachable in EC pools whose pg_minsize equals the number of data chunks (N+1 at the default pg_minsize, or N+K with pg_minsize lowered); with K >= 3 at the default pg_minsize only if one more OSD of the write set is down too. Replicated pools write stable versions with immediate_commit=all and are not affected.

Not changed: with auto_scrub on, the state report at the end of peering can carry a new scrub plan and set reporting_epoch before the flush or the first write runs; then neither adds the current set. That was already so for writes before #131.

Found: by reading the code while checking #131's epoch report against the write path, then reproduced in osd_test; not seen in a run.

Tested: osd_test: test_degraded_write_primary_lost gets a variant where the peering first rolls back an object on the primary (EC 2+1/pg_minsize 2 and 3+1/pg_minsize 3); without the fix it fails at assert(has_history_set(etcd_pg_history(f), cur_set)), and with the check skipped the PG activates without OSD 1 and the object ends incomplete. test_peering_flush_waiting_batch_repeer now expects the current set in the history. Whole osd_test passes; test_pg_chaos --seeds 1-200 with and without --ec passes before and after.

Contributor Name

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

CLA

### Description Since #131 the peering flush reports a new epoch itself, so that the holders of the versions it stabilizes are in the PG history first. The write path adds the current OSD set of a degraded PG to the history only when it reports the epoch (`report_epoch()`, `if (pg.epoch > pg.reporting_epoch)`). After a flush has reported it, the first degraded write of the same peering finds the epoch reported and skips that, so the degraded set never reaches the history. Sequence, EC 2+1 with pg_minsize 2, immediate_commit=all: OSD 3 is down, the PG peers on {1,2} and rolls back a leftover unstable version (the flush reports epoch E). A client write goes to OSDs 1 and 2, OSD 1 stabilizes its own part and is lost before OSD 2 stabilizes. The PG peers on {2,3}: the history has {1,2,3} but not {1,2}, so it activates and rolls OSD 2's part back. OSD 1 returns with a lone stable version and the object stays incomplete. Before #131 the write's own epoch report put {1,2} into the history and the PG waited for OSD 1. The fix reports the epoch from the flush with `report_epoch()`, so the current OSD set goes into the history together with the holders, as it would on the first write. The cost: a degraded PG that flushed something but got no write in that peering now also waits for its last OSD set at the next peering, the same as after any single write. Reachable in EC pools whose pg_minsize equals the number of data chunks (N+1 at the default pg_minsize, or N+K with pg_minsize lowered); with K >= 3 at the default pg_minsize only if one more OSD of the write set is down too. Replicated pools write stable versions with immediate_commit=all and are not affected. Not changed: with auto_scrub on, the state report at the end of peering can carry a new scrub plan and set `reporting_epoch` before the flush or the first write runs; then neither adds the current set. That was already so for writes before #131. Found: by reading the code while checking #131's epoch report against the write path, then reproduced in osd_test; not seen in a run. Tested: osd_test: `test_degraded_write_primary_lost` gets a variant where the peering first rolls back an object on the primary (EC 2+1/pg_minsize 2 and 3+1/pg_minsize 3); without the fix it fails at `assert(has_history_set(etcd_pg_history(f), cur_set))`, and with the check skipped the PG activates without OSD 1 and the object ends incomplete. `test_peering_flush_waiting_batch_repeer` now expects the current set in the history. Whole osd_test passes; test_pg_chaos `--seeds 1-200` with and without `--ec` passes before and after. ### 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-12-01 21:56:09 +03:00
Since the peering flush reports a new epoch itself, to get the holders
of the versions it stabilizes into the history first, the first
degraded write of that epoch finds the epoch already reported and no
longer adds the current OSD set to the history. If the primary then
stabilizes its own part of that write and is lost before the others
stabilize theirs, the PG can activate without it and roll the other
parts back. The primary comes back with a lone stable part, and the
object stays incomplete.

Report the epoch from the flush with report_epoch(), as writes do, so
a degraded PG's current OSD set goes into the history with it. This is
reachable in EC pools whose pg_minsize equals the number of data
chunks, e.g. N+1 with the default pg_minsize.
vitalif merged commit fae749d515 into master 2026-12-02 01:36:19 +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#217
No description provided.