Repository navigation
tentacle: osd/PeeringState: Record the departing primary's rebuild segment on handover & survive a PG split. - #71671
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]>
(cherry picked from commit 033c43d)
Conflicts:
src/osd/osd_perf_counters.cc
- Removed a bunch of perf counters definitions not yet available in tentacle.
src/test/osd/TestPeeringState.cc
- Removed the src/test/osd/TestPeeringState.cc file as it's not yet
intoduced in tentacle
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]>
(cherry picked from commit 7078f47)
src/osd/PeeringState.cc
- Removed a couple of increment_stats_invalidations_counter() calls for
rs_pg_split_parent_stats_invalidated and rs_pg_split_child_stats_invalidated
which don't exist in Tentacle yet.
There was a problem hiding this comment.
Ceph Release Engineering Audit Report
Commit Parity Visualizer
| BACKPORT PR #71671 | SOURCE PR |
SOURCE STATUS |
|---|---|---|
| 82b46c4 osd/PeeringState: Record the departing primary's rebuild segment on handover | PR #71439 | 033c43d osd/PeeringState: Record the departing primary's rebuild segment on handover |
| f0aa005 osd/PeeringState: make rebuild-stats latch survive a PG split | 7078f47 osd/PeeringState: make rebuild-stats latch survive a PG split |
Automated Backport Parity Review - Cherry-Pick Conflicts / Deviations
A conflict or deviation was detected during the simulation of this backport. The code in this PR does not match a clean cherry-pick of the upstream commits.
This does not necessarily indicate an issue but a maintainer should review.
**Click to expand conflict summaries.**
Deviation in Backport 82b46c4 (cherry-pick of 033c43d)
Affected File(s)
src/osd/osd_perf_counters.ccsrc/test/osd/TestPeeringState.cc
Range Diff
Click to expand
--- Original (033c43da)
+++ Backport (82b46c47)
@@ -67,3 +67,11 @@
Fixes: https://tracker.ceph.com/issues/80117
Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit 033c43da7414d5058bc337e38faa14d6e028c2ec)
+
+Conflicts:
+ src/osd/osd_perf_counters.cc
+- Removed a bunch of perf counters definitions not yet available in tentacle.
+ src/test/osd/TestPeeringState.cc
+- Removed the src/test/osd/TestPeeringState.cc file as it's not yet
+ intoduced in tentacle
================================================================================
RANGE DIFF
================================================================================
1: 033c43da741 ! 1: 82b46c4713c osd/PeeringState: Record the departing primary's rebuild segment on handover
@@ Commit message
Fixes: https://tracker.ceph.com/issues/80117
Signed-off-by: Sridhar Seshasayee <[email protected]>
+ (cherry picked from commit 033c43da7414d5058bc337e38faa14d6e028c2ec)
+
+ Conflicts:
+ src/osd/osd_perf_counters.cc
+ - Removed a bunch of perf counters definitions not yet available in tentacle.
+ src/test/osd/TestPeeringState.cc
+ - Removed the src/test/osd/TestPeeringState.cc file as it's not yet
+ intoduced in tentacle
## qa/standalone/osd/osd-recovery-stats.sh ##
@@ qa/standalone/osd/osd-recovery-stats.sh: function TEST_rebuild_perf_ec_increments() {
@@ src/osd/PeeringState.h: public:
## src/osd/osd_perf_counters.cc ##
@@ src/osd/osd_perf_counters.cc: PerfCounters *build_recoverystate_perf(CephContext *cct) {
- rs_perf.add_u64_counter(rs_update_stats_invalidated, "update_stats_invalidated", "Number of times pg stats received invalidations during stats updates");
- rs_perf.add_u64_counter(rs_append_log_stats_invalidated, "append_log_stats_invalidated", "Number of times pg stats received invalidations when appending new log entries");
- 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_waitupthru_latency, "waitupthru_latency", "Waitupthru recovery state latency");
+ rs_perf.add_time_avg(rs_notrecovering_latency, "notrecovering_latency", "Notrecovering recovery state latency");
+ rs_perf.add_u64_counter(rs_stats_invalidated, "stats_invalidated", "Number of times pg stats received invalidations");
- 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",
@@ src/osd/osd_perf_counters.cc: PerfCounters *build_recoverystate_perf(CephContext
NULL, PerfCountersBuilder::PRIO_USEFUL);
return rs_perf.create_perf_counters();
-
- ## src/test/osd/TestPeeringState.cc ##
-@@ src/test/osd/TestPeeringState.cc: TEST_F(PeeringStateTest, RebuildStatsCountAccumulates) {
-
- // ============================================================================
- // Test 5: Latch is discarded when the OSD loses its primary role mid-rebuild.
-+// But the departing primary's own in-progress segment is now recorded rather
-+// than silently discarded.
- //
--// If a new interval begins while rebuild_start_time is set and the OSD
--// transitions from primary to stray, clear_primary_state() must discard the
--// stale latch so no spurious rebuild event is emitted for a recovery that the
--// OSD no longer owns.
-+// The original interim design discarded the stale latch during the
-+// primary -> stray transition with no recording. This discarded real rebuild
-+// episodes whenever the failed OSD was held primary for the affected PG.
- // ============================================================================
--TEST_F(PeeringStateTest, RebuildStatsLatchClearedOnRoleChange) {
-- dout(0) << "== RebuildStatsLatchClearedOnRoleChange ==" << dendl;
-+TEST_F(PeeringStateTest, RebuildStatsRecordsSegmentOnRoleChange) {
-+ dout(0) << "== RebuildStatsRecordsSegmentOnRoleChange ==" << dendl;
- test_create_peering_state();
- test_init();
- test_event_initialize();
-@@ src/test/osd/TestPeeringState.cc: TEST_F(PeeringStateTest, RebuildStatsLatchClearedOnRoleChange) {
- ASSERT_NE(get_ps(0)->get_rebuild_start_time(), utime_t())
- << "latch must be set before role change";
-
-+ // Sleep so the departing primary's segment has a real, nonzero duration
-+ // to record -- mirrors the sleep pattern used by the other RebuildStats*
-+ // tests for the same reason.
-+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
-+
- // --- Phase 2: change the primary before recovery completes. ---
- // Swap acting[0] from OSD 0 to OSD 7. OSD 0 leaves the acting set
- // entirely and becomes a stray; OSD 7 takes over as primary.
-@@ src/test/osd/TestPeeringState.cc: TEST_F(PeeringStateTest, RebuildStatsLatchClearedOnRoleChange) {
- test_init(7);
- test_event_initialize(7);
-
-- // advance_map on OSD 0: the new acting set excludes OSD 0, so
-- // should_restart_peering()->start_peering_interval() resets the
-- // three latch variables since the role of OSD 0 is now changed.
-+ // should_restart_peering()->start_peering_interval() now closes out and
-+ // records OSD 0's own segment before resetting the three latch variables.
- test_event_advance_map();
-
-- // --- Phase 3: verify latch is cleared on the old primary. ---
-+ // --- Phase 3: latch fields still reset on the departing primary. ---
-+ // This part of the behavior is unchanged from before: a stale
-+ // start time/baseline must never be reused across a role change.
- EXPECT_EQ(get_ps(0)->get_rebuild_start_time(), utime_t());
- EXPECT_EQ(get_ps(0)->get_rebuild_base_recovered(), 0);
- EXPECT_FALSE(get_ps(0)->get_rebuild_had_redundancy_loss());
-
-- // No rebuild record must have been emitted: the latch was discarded, not
-- // fired. A spurious emission here would record a duration spanning a
-- // recovery that OSD 0 did not complete.
-+ // --- Phase 4: the segment IS now recorded, not silently dropped. ---
-+ // OSD 0 had real degraded objects at latch time (rebuild_had_redundancy_
-+ // loss == true), so the genuine-event filter passes even though no
-+ // recovery I/O had completed yet (delta_recovered == 0 at handover time).
- auto [sum_ns, count] = perf_osd0->get_tavg_ns(rs_pg_rebuild_duration);
-- EXPECT_EQ(count, 0u);
-- EXPECT_EQ(sum_ns, 0u);
-+ EXPECT_EQ(count, 1u)
-+ << "the departing primary's segment must be recorded, not discarded";
-+ EXPECT_GT(sum_ns, 0u);
- }
-
- // ============================================================================
-@@ src/test/osd/TestPeeringState.cc: TEST_F(PeeringStateTest, RebuildStatsLatchSurvivesSamePrimaryIntervalRestart) {
- EXPECT_EQ(count, 0u);
- }
-
-+// ============================================================================
-+// Test 7: A PG that changes primary TWICE while continuously vulnerable
-+// records a SEPARATE partial segment on each departing primary, instead of
-+// losing the whole episode, and demonstrates its accepted trade-off concretely:
-+// one true, continuous vulnerability episode is recorded as THREE separate
-+// avgcount samples, not one.
-+//
-+// The test chains two primary handovers back to back (0 -> 7 -> 8) while
-+// up_acting keeps accumulating every historical OSD (modify_up_acting() only
-+// ever pushes; see osd_down() for the only helper that erases).
-+// test_event_advance_map() with no target therefore re-processes
-+// already-departed OSDs on the second handover too; this is expected to be
-+// harmless because try_record_rebuild_segment() is only invoked when
-+// rebuild_start_time != utime_t(), and the departing OSD's latch is
-+// unconditionally reset to utime_t() immediately after its segment is recorded
-+// on the first handover -- so a redundant advance_map on an already-departed
-+// OSD cannot re-fire or double-record.
-+// ============================================================================
-+TEST_F(PeeringStateTest, RebuildStatsMultiHopHandoverRecordsEachSegment) {
-+ dout(0) << "== RebuildStatsMultiHopHandoverRecordsEachSegment ==" << dendl;
-+ test_create_peering_state();
-+ test_init();
-+ test_event_initialize();
-+ eversion_t v = test_append_log_entry();
-+ test_peering();
-+ verify_all_active_clean(v, eversion_t());
-+
-+ // Stamp last_clean so the new_failure guard is satisfied for OSD 0.
-+ call_prepare_stats(acting_primary); // acting_primary = OSD 0
-+
-+ // --- Degrade the PG while OSD 0 is primary. ---
-+ // Replace acting[1] (OSD 1) with OSD 9; OSD 9 needs recovery. This keeps
-+ // the PG degraded (rebuild_had_redundancy_loss latches true at every
-+ // hop) all the way through both handovers below, without needing to
-+ // actually complete the recovery until the very end.
-+ modify_up_acting(1, 9);
-+ test_create_peering_state(9, 1);
-+ test_init(9);
-+ test_event_initialize(9);
-+ test_peering();
-+ // PG is now active+recovering+degraded; OSD 0 remains primary.
-+
-+ PerfCounters *perf_osd0 = get_listener(0)->recoverystate_perf;
-+
-+ // Latch fires on OSD 0.
-+ call_prepare_stats(acting_primary);
-+ ASSERT_NE(get_ps(0)->get_rebuild_start_time(), utime_t())
-+ << "latch must be set before the first handover";
-+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
-+
-+ // --- Hop 1: OSD 0 -> OSD 7. OSD 0 leaves the acting set entirely. ---
-+ modify_up_acting(0, 7);
-+ acting_primary = 7;
-+ up_primary = 7;
-+ test_create_peering_state(7, 0);
-+ test_init(7);
-+ test_event_initialize(7);
-+ test_event_advance_map(); // closes out and records OSD 0's segment
-+ test_peering();
-+
-+ // OSD 0's segment must be recorded now, not silently discarded.
-+ {
-+ auto [sum_ns, count] = perf_osd0->get_tavg_ns(rs_pg_rebuild_duration);
-+ EXPECT_EQ(count, 1u)
-+ << "OSD 0's segment must be recorded on the first handover";
-+ EXPECT_GT(sum_ns, 0u);
-+ }
-+ EXPECT_EQ(get_ps(0)->get_rebuild_start_time(), utime_t())
-+ << "OSD 0's latch fields must still reset after recording";
-+
-+ PerfCounters *perf_osd7 = get_listener(7)->recoverystate_perf;
-+
-+ // OSD 7 must reliably re-arm its own fresh latch: the PG is still
-+ // degraded (OSD 9 still needs recovery), and last_change was just
-+ // bumped by this interval restart while last_clean is still the old,
-+ // pre-failure value -- confirmed reliable in the pg-state-machine skill.
-+ call_prepare_stats(acting_primary);
-+ ASSERT_NE(get_ps(7)->get_rebuild_start_time(), utime_t())
-+ << "a fresh primary must reliably re-arm mid-vulnerability";
-+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
-+
-+ // --- Hop 2: OSD 7 -> OSD 8. OSD 7 leaves the acting set entirely. ---
-+ modify_up_acting(0, 8);
-+ acting_primary = 8;
-+ up_primary = 8;
-+ test_create_peering_state(8, 0);
-+ test_init(8);
-+ test_event_initialize(8);
-+ test_event_advance_map(); // closes out and records OSD 7's segment
-+ test_peering();
-+
-+ // OSD 7's segment must ALSO be recorded, independently of OSD 0's.
-+ {
-+ auto [sum_ns, count] = perf_osd7->get_tavg_ns(rs_pg_rebuild_duration);
-+ EXPECT_EQ(count, 1u)
-+ << "OSD 7's segment must be recorded on the second handover";
-+ EXPECT_GT(sum_ns, 0u);
-+ }
-+
-+ PerfCounters *perf_osd8 = get_listener(8)->recoverystate_perf;
-+
-+ // OSD 8 arms its own fresh latch the same way OSD 7 did.
-+ call_prepare_stats(acting_primary);
-+ ASSERT_NE(get_ps(8)->get_rebuild_start_time(), utime_t());
-+ std::this_thread::sleep_for(std::chrono::milliseconds(10));
-+
-+ // --- Finally: drive the recovery to completion under OSD 8. ---
-+ test_recover_got(8, v);
-+ test_begin_peer_recover(9, 1);
-+ test_on_peer_recover(9, 1, v);
-+ test_recover_got(9, v);
-+ test_object_recovered();
-+ test_event_all_replicas_recovered();
-+ verify_all_active_clean(v, eversion_t());
-+ call_prepare_stats(acting_primary); // "reached-clean" record fires on OSD 8
-+
-+ auto [sum_ns, count] = perf_osd8->get_tavg_ns(rs_pg_rebuild_duration);
-+ EXPECT_EQ(count, 1u)
-+ << "OSD 8's own segment must be recorded once it reaches clean";
-+ EXPECT_GT(sum_ns, 0u);
-+}
-+
- // ============================================================================
- // Main
- // ============================================================================Deviation in Backport f0aa005 (cherry-pick of 7078f47)
Affected File(s)
src/osd/PeeringState.cc
Range Diff
Click to expand
--- Original (7078f47e)
+++ Backport (f0aa0058)
@@ -21,3 +21,9 @@
recorded duration reflects the time that it alone spent rebuilding the data.
Signed-off-by: Sridhar Seshasayee <[email protected]>
+(cherry picked from commit 7078f47e9e095b9964b5d3d7210fc6d3c2c83ee4)
+
+ src/osd/PeeringState.cc
+- Removed a couple of increment_stats_invalidations_counter() calls for
+ rs_pg_split_parent_stats_invalidated and rs_pg_split_child_stats_invalidated
+ which don't exist in Tentacle yet.
================================================================================
RANGE DIFF
================================================================================
1: 7078f47e9e0 ! 1: f0aa005880b osd/PeeringState: make rebuild-stats latch survive a PG split
@@ Commit message
recorded duration reflects the time that it alone spent rebuilding the data.
Signed-off-by: Sridhar Seshasayee <[email protected]>
+ (cherry picked from commit 7078f47e9e095b9964b5d3d7210fc6d3c2c83ee4)
+
+ src/osd/PeeringState.cc
+ - Removed a couple of increment_stats_invalidations_counter() calls for
+ rs_pg_split_parent_stats_invalidated and rs_pg_split_child_stats_invalidated
+ which don't exist in Tentacle yet.
## qa/standalone/osd/osd-recovery-stats.sh ##
@@ qa/standalone/osd/osd-recovery-stats.sh: function TEST_rebuild_perf_empty_pg_not_counted() {
@@ qa/standalone/osd/osd-recovery-stats.sh: function TEST_rebuild_perf_empty_pg_not
## src/osd/PeeringState.cc ##
@@ src/osd/PeeringState.cc: void PeeringState::split_into(
- child->info.last_epoch_started = info.last_epoch_started;
- child->info.last_interval_started = info.last_interval_started;
+ increment_stats_invalidations_counter(info.stats.stats_invalid);
+ increment_stats_invalidations_counter(child->info.stats.stats_invalid);
+ // rebuild-stats: Make the child inherit the parent's latch. Otherwise the
+ // child's share of a pre-split, still-ongoing failure would understate its
@@ src/osd/PeeringState.cc: void PeeringState::split_into(
+ child->rebuild_start_time = rebuild_start_time;
+ child->rebuild_had_redundancy_loss = rebuild_had_redundancy_loss;
+
- increment_stats_invalidations_counter(rs_pg_split_parent_stats_invalidated,
- info.stats.stats_invalid);
- increment_stats_invalidations_counter(rs_pg_split_child_stats_invalidated,
+ // There can't be recovery/backfill going on now
+ int primary, up_primary;
+ vector<int> newup, newacting;
@@ src/osd/PeeringState.cc: void PeeringState::finish_split_stats(
const object_stat_sum_t& stats, ObjectStore::Transaction &t)
{How to proceed:
- Authors (Genuine Conflicts): If this is a genuine conflict requiring manual resolution, ensure your resolution is correct. You must explain the conflict resolution in the commit message (e.g., leave the standard Git
Conflicts:block intact) and include an explanation for changes. - Authors (Need Help?): Reach out to the Component Lead for technical guidance on complex code conflicts.
- Component Leads (Review): Please review the Range Diff(s) above to verify the author's manual conflict resolution is correct for this release branch. If the deviation is intentional, documented, and approved then the component lead or @ceph/ceph-release-manager can bypass this check by commenting
/audit override.
Be familiar with the rules and guidelines for writing backports.
🛟 Need Help?
If you need technical help resolving these issues, please consult with the Component Lead. If you need administrative overrides, please see the #ceph-upstream-releases channel on Slack and request a review from the @ceph/ceph-release-manager.
📋 Component Lead / Release Manager
To override the audit failure, apply releng-audit-override label or comment /audit override.
When you are ready for a new audit, please remove the releng-audit-fail label or comment /audit retest.
|
This PR has been added to wip-bharath20-testing-20260917.060858-tentacle. |
|
@rzarzynski conflicts need reviewed (backport audit). |
|
/audit override |
|
✅ Audit Override Applied by @rzarzynski. |
|
@batrick we need to merge this PR please, thanks. |
backport tracker: https://tracker.ceph.com/issues/80426
backport of #71439
parent tracker: https://tracker.ceph.com/issues/80117
this backport was staged using ceph-backport.sh version 16.0.0.6848
find the latest version at https://github.com/ceph/ceph/blob/main/src/script/ceph-backport.sh