Repository navigation
osd/PeeringState: Record the departing primary's rebuild segment on handover & survive a PG split. - #71439
Merged
sseshasa merged 2 commits intoSep 9, 2026
Conversation
…andover
Whenever a PG's primary changes hands while it is vulnerable, the in-memory
rebuild-time latch was discarded incorrectly by start_peering_interval()'s
reset with no recording step at all. Every OSD that touched a multi-handover
PG ended up with pg_rebuild_duration avgcount=0 despite real, confirmed
recovery activity, while the one PG whose primary never changed hands recorded
the correct full duration. This is not a rare corner case: it reproduces
whenever the failed OSD was a primary for the affected PG, which is the common
case for any OSD restart, not the exception.
This is a scoped mitigation, for the interim solution where the departing
primary's rebuild segment is now recorded on handover.
Changes:
- New PeeringState::try_record_rebuild_segment(end_time, reason): factored
out of prepare_stats_for_publish()'s existing "reached clean" record
branch (no behavior change there beyond an added trailing "reason=" field
in the log line.
- start_peering_interval(): When an OSD is losing the primary role
(was_old_primary && !is_primary()) while rebuild_start_time is still
armed, call try_record_rebuild_segment() before the existing unconditional
reset. The "gaining primary" side needs no change which already reliably
latches the fresh primary while mid-rebuild. Only the losing-primary side
was silently dropping collected stats data.
- osd_perf_counters.cc: Rename the exposed pg_rebuild_duration perf counter
to pg_vulnerability_duration and extend the description string. This only
changes the externally-visible Prometheus/perf-schema facing name and its
description.
Rationale: The counter has always measured a vulnerability window (onset
of redundancy loss to resolution), not literal rebuild/data-movement time.
This accounts for the case where a recorded duration includes several
minutes of a PG sitting undersized+degraded with zero recovery activity
possible (no spare OSD) before any data moved at all. However, note that in
this scenario if no data was moved at all and the PG returns to active+clean,
the window is excluded and not recorded (see caveats below).
Known caveats:
- excludes windows where no data was ever recovered or lost (empty PGs), and
- a primary handover mid-episode is recorded as a separate sample per OSD
segment, so avgcount can exceed the true incident count.
- TestPeeringState.cc:
a) RebuildStatsLatchClearedOnRoleChange renamed to
RebuildStatsRecordsSegmentOnRoleChange and rewritten -- it previously
asserted count==0 after a primary handover as the *correct* behavior;
that assertion is now the opposite (count==1, sum>0), reflecting the
deliberate behavior change, not a regression. The other five
RebuildStats* tests are unaffected.
b) Adds RebuildStatsMultiHopHandoverRecordsEachSegment: a PG whose primary
changes twice while continuously vulnerable (OSD 0 -> OSD 7 -> OSD 8, PG
degraded throughout, recovery only completing under the final primary)
must record three separate partial segments -- one per primary -- rather
than losing the whole episode.
- osd-recovery-stats.sh:
a) Modify the recoverystate_perf.pg_rebuild_duration references to
recoverystate_perf.pg_vulnerability_duration in an existing test.
b) Add TEST_rebuild_perf_multihop_handover and
TEST_rebuild_perf_empty_pg_not_counted to cover the multi-hop primary
handover and empty PG not recorded scenarios respectively.
Fixes: https://tracker.ceph.com/issues/80117
Signed-off-by: Sridhar Seshasayee <[email protected]>
A PG split (split_into()), triggered by a pg_num increase during map advance
should not leave a child PG's rebuild-stats latch fields (rebuild_start_time,
rebuild_base_recovered, rebuild_had_redundancy_loss) at their default, unarmed
values regardless of whether the parent was already latched as vulnerable at
split time. Leaving it at default would cause it to understate its true
duration or vanish from delta_recovered's filter.
changes:
1. split_into(): Make the child inherit the parent's latch.
2. finish_split_stats(): Re-anchor rebuild_base_recovered to the just-applied,
already-redistributed value of num_objects_recovered. This preserves the
true rebuild_start_time/duration while ensuring delta_recovered only ever
reflects genuine recovery happening after this point.
3. Add a standalone test called TEST_rebuild_perf_pg_split_inherits_latch()
to exercise the split PG logic and verify that the latch is inherited by
the child PG (confirm no latch was fired) and that the final child PG's
recorded duration reflects the time that it alone spent rebuilding the data.
Signed-off-by: Sridhar Seshasayee <[email protected]>
rzarzynski
approved these changes
Sep 2, 2026
Comment on lines
+4593
to
+4603
| * 5. A primary handover mid-vulnerability window closes out and records | ||
| * the departing OSD's own segment instead of silently discarding it. | ||
| * This means a PG that changes primary N times while continuously | ||
| * vulnerable is recorded as N separate rebuild_duration samples | ||
| * (whose durations sum to roughly, not exactly, the true total episode | ||
| * length) rather than one -- a real, understood, and accepted | ||
| * trade-off for this interim solution: avgcount can overcount the true | ||
| * number of distinct redundancy-loss incidents whenever a handover | ||
| * occurs mid-episode, though avgtime/the summed exposure duration stay | ||
| * roughly accurate. A PG whose primary never changes is entirely | ||
| * unaffected and continues to produce exactly one sample. |
| rs_perf.add_u64_counter(rs_merge_log_stats_invalidated, "merge_log_stats_invalidated", "Number of times pg stats received invalidations during merging of log entries"); | ||
| rs_perf.add_time_avg(rs_pg_rebuild_duration, "pg_rebuild_duration", | ||
| "Average PG rebuild duration on this OSD (primary role only)", | ||
| rs_perf.add_time_avg(rs_pg_rebuild_duration, "pg_vulnerability_duration", |
Contributor
There was a problem hiding this comment.
We're replacing one perf counter with another. I assume there is no external dependency on it.
Contributor
Author
There was a problem hiding this comment.
This is a new counter created in the interim solution for consumption by Prometheus. In this PR, only the externally exposed name is changed to reflect it's true purpose. There's no other external dependency on this. Prometheus will consume the modified exposed name i.e. pg_vulnerability_duration. The full solution too will retain the same name.
Contributor
|
This PR has been added to wip-bharath10-testing-20260903.050751-main. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes:
Whenever a PG's primary changes hands while it is vulnerable, the in-memory
rebuild-time latch was discarded incorrectly by start_peering_interval()'s
reset with no recording step at all. Every OSD that touched a multi-handover
PG ended up with pg_rebuild_duration avgcount=0 despite real, confirmed
recovery activity, while the one PG whose primary never changed hands recorded
the correct full duration. This is not a rare corner case: it reproduces
whenever the failed OSD was a primary for the affected PG, which is the common
case for any OSD restart, not the exception.
This is a scoped mitigation, for the interim solution where the departing
primary's rebuild segment is now recorded on handover.
osd_perf_counters.cc: Rename the exposedpg_rebuild_durationperf counterto
pg_vulnerability_durationand extend the description string. This onlychanges the externally-visible Prometheus/perf-schema facing name and its
description.
Rationale: The counter has always measured a vulnerability window (onset
of redundancy loss to resolution), not literal rebuild/data-movement time.
This accounts for the case where a recorded duration includes several
minutes of a PG sitting undersized+degraded with zero recovery activity
possible (no spare OSD) before any data moved at all. However, note that in
this scenario if no data was moved at all and the PG returns to active+clean,
the window is excluded and not recorded (see caveats below).
A PG split (
split_into()), triggered by a pg_num increase during map advanceshould not leave a child PG's rebuild-stats latch fields (
rebuild_start_time,rebuild_base_recovered,rebuild_had_redundancy_loss) at their default, unarmedvalues regardless of whether the parent was already latched as vulnerable at
split time. Leaving it at default would cause it to understate its true
duration or vanish from
delta_recovered's filter.Fixes: https://tracker.ceph.com/issues/80117
Signed-off-by: Sridhar Seshasayee [email protected]
Contribution Guidelines
To sign and title your commits, please refer to Submitting Patches to Ceph.
If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.
When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an
xbetween the brackets:[x]. Spaces and capitalization matter when checking off items this way.Checklist
Show available Jenkins commands
jenkins test classic perfJenkins Job | Jenkins Job Definitionjenkins test crimson perfJenkins Job | Jenkins Job Definitionjenkins test signedJenkins Job | Jenkins Job Definitionjenkins test make checkJenkins Job | Jenkins Job Definitionjenkins test make check arm64Jenkins Job | Jenkins Job Definitionjenkins test submodulesJenkins Job | Jenkins Job Definitionjenkins test dashboardJenkins Job | Jenkins Job Definitionjenkins test dashboard cephadmJenkins Job | Jenkins Job Definitionjenkins test apiJenkins Job | Jenkins Job Definitionjenkins test docsReadTheDocs | Github Workflow Definitionjenkins test ceph-volume allJenkins Jobs | Jenkins Jobs Definitionjenkins test windowsJenkins Job | Jenkins Job Definitionjenkins test rook e2eJenkins Job | Jenkins Job DefinitionYou must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.