osd: Move the PG epoch only when reporting it for the first modification #219

Merged
vitalif merged 1 commits from koolkhel/vitastor:peering-flush-stale-release into master 2026-12-02 13:11:30 +03:00
Contributor

Description

A history report that only changes next_scrub or clears the history (plan_scrub, the end of a scrub, the cleanup of a clean or left_on_dead PG) also wrote pg.epoch and set reporting_epoch to it. If the PG re-peered before that report landed, the new peering took the same epoch (it starts from reported_epoch), report_epoch() saw it as already being reported, and the old report, without the new peering's OSD sets, released its flush. The flush then stabilized versions whose holders were not in the history. If the stabilized OSD is then lost, the next peering can activate without it and roll the other parts back, leaving a lone stable part.

As discussed: a new epoch is needed only for the first modification. Only report_epoch(), which runs before the first write or flush of an epoch, now writes the new epoch and moves reporting_epoch. Other history updates write the epoch etcd already has, or the one report_epoch() has in flight, so they can't release a flush of a newer peering.

The OSD sets and all_peers are written as the PG has them. For the two cleanups that is their purpose. For a next_scrub update they may already include the sets of a newer peering whose epoch is not reported yet: that only adds possible holders under the old epoch and releases nothing. Keeping them exactly as in etcd would need a per-PG copy of the last written history; I can add it if you prefer.

The two-primary case from the first version of this PR is dropped: that one is for PG locks.

Found: by reading the code, then reproduced in osd_test; not seen in a run. It needs a history-only report still in flight when the PG re-peers, i.e. etcd slower than a peer reconnect.

Tested: test_peering_flush_same_epoch_repeer (EC 2+2, auto_scrub). Without the fix the scrub report releases the flush before OSDs 3 and 4 are in the history, and the PG then activates without OSD 3 (osd_test.cpp: Assertion '!early && !active_without && r.active && !r.incomplete'). Whole osd_test passes with the fix.

Contributor Name

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

CLA

### Description A history report that only changes next_scrub or clears the history (plan_scrub, the end of a scrub, the cleanup of a clean or left_on_dead PG) also wrote pg.epoch and set reporting_epoch to it. If the PG re-peered before that report landed, the new peering took the same epoch (it starts from reported_epoch), report_epoch() saw it as already being reported, and the old report, without the new peering's OSD sets, released its flush. The flush then stabilized versions whose holders were not in the history. If the stabilized OSD is then lost, the next peering can activate without it and roll the other parts back, leaving a lone stable part. As discussed: a new epoch is needed only for the first modification. Only report_epoch(), which runs before the first write or flush of an epoch, now writes the new epoch and moves reporting_epoch. Other history updates write the epoch etcd already has, or the one report_epoch() has in flight, so they can't release a flush of a newer peering. The OSD sets and all_peers are written as the PG has them. For the two cleanups that is their purpose. For a next_scrub update they may already include the sets of a newer peering whose epoch is not reported yet: that only adds possible holders under the old epoch and releases nothing. Keeping them exactly as in etcd would need a per-PG copy of the last written history; I can add it if you prefer. The two-primary case from the first version of this PR is dropped: that one is for PG locks. Found: by reading the code, then reproduced in osd_test; not seen in a run. It needs a history-only report still in flight when the PG re-peers, i.e. etcd slower than a peer reconnect. Tested: `test_peering_flush_same_epoch_repeer` (EC 2+2, auto_scrub). Without the fix the scrub report releases the flush before OSDs 3 and 4 are in the history, and the PG then activates without OSD 3 (`osd_test.cpp`: `Assertion '!early && !active_without && r.active && !r.incomplete'`). Whole osd_test passes with the fix. ### 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 22:33:26 +03:00
A peering flush and writes wait until etcd has the PG history at the
PG's epoch, so that the holders of the versions they stabilize are
recorded first. The wait ended on the epoch number alone, so another
report of the same epoch without our sets could end it: a report sent
before a re-peer at the same epoch (a scrub plan, clearing the history
of an active+left_on_dead PG), or the history of another primary that
took the PG while this one was cut off from etcd, when the watch
catch-up delivers /pg/history before the change that stops the PG. The
flush then stabilizes versions whose holders are not in the history,
and a lone stable part can be left after the next primary rolls the
other parts back.

Re-peer instead when the reported history does not include our sets.
Owner
  1. А какого хрена repeer если живая операция, почему inflight не закрыл
  2. Это сплитбрейн, нужно лечить через включение pg<locks
1. А какого хрена repeer если живая операция, почему inflight не закрыл 2. Это сплитбрейн, нужно лечить через включение pg<locks
koolkhel force-pushed peering-flush-stale-release from c6f3c72aa3 to e30b0dafd5 2026-12-02 12:48:37 +03:00 Compare
koolkhel changed title from osd: Resume ops waiting for the PG epoch only if etcd has our OSD sets to osd: Move the PG epoch only when reporting it for the first modification 2026-12-02 12:48:40 +03:00
vitalif merged commit ec74399871 into master 2026-12-02 13:11:30 +03:00
Sign in to join this conversation.
No Reviewers
No Label
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: vitalif/vitastor#219
No description provided.