Project

General

Profile

Actions

Bug #79028

closed
SS SS

[pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate.

Bug #79028: [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate.

Added by Sridhar Seshasayee 4 months ago. Updated 2 months ago.

Status:
Resolved
Priority:
High
Category:
Correctness/Safety
Target version:
-
Due date:
% Done:

0%

Source:
Backport:
umbrella, tentacle
Regression:
No
Severity:
3 - minor
Reviewed:
Affected Versions:
ceph-qa-suite:
Component(RADOS):
OSD
Pull request ID:
Tags (freeform):
Fixed In:
v21.3.0-1945-g83cf4c1aa6
Released In:
Upkeep Timestamp:
2026-09-29T13:06:29+00:00

Description

For scenarios involving PG recovery, the PG rebuild stats are observed not be updated
after legitimately going through the recovery process. For e.g., an OSD on which PGs
genuinely underwent recovery, the perf dump of the rebuild_duration shows:

# ceph tell osd.5 perf dump
        "pg_rebuild_duration": {
            "avgcount": 0,
            "sum": 0.000000000,
            "avgtime": 0.000000000
        },
        "pg_rebuild_max_secs": 0,
        "pg_rebuild_min_secs": 0
    },

Looking at the OSD logs, it can be seen that the rebuild start latch was recorded:

PG state was undersized+degraded at 2026-08-04T07:14:34


2026-08-04T07:14:34.220+0000 7f9eaa478640 20 osd.5 pg_epoch: 940 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=939/940 n=1401 ec=923/923 lis/c=936/936 les/c/f=937/937/0 sis=939) [5,44] r=0 lpr=939 pi=[936,939)/1 crt=925'1465 lcod 925'1464 mlcod 0'0 activating+undersized+degraded mbc={}] PeeringState::prepare_stats_for_publish reporting purged_snaps []
2026-08-04T07:14:34.220+0000 7f9eaa478640 15 osd.5 pg_epoch: 940 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=939/940 n=1401 ec=923/923 lis/c=936/936 les/c/f=937/937/0 sis=939) [5,44] r=0 lpr=939 pi=[936,939)/1 crt=925'1465 lcod 925'1464 mlcod 0'0 activating+undersized+degraded mbc={}] PeeringState::prepare_stats_for_publish rebuild-stats: latched failure start for 10.0 at 2026-08-04T07:14:34.222032+0000
2026-08-04T07:14:34.220+0000 7f9eaa478640 15 osd.5 pg_epoch: 940 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=939/940 n=1401 ec=923/923 lis/c=936/936 les/c/f=937/937/0 sis=939) [5,44] r=0 lpr=939 pi=[936,939)/1 crt=925'1465 lcod 925'1464 mlcod 0'0 activating+undersized+degraded mbc={}] PeeringState::prepare_stats_for_publish publish_stats_to_osd 940:4360
2026-08-04T07:14:34.220+0000 7f9eaa478640 10 osd.5 pg_epoch: 940 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=939/940 n=1401 ec=923/923 lis/c=936/936 les/c/f=937/937/0 sis=939) [5,44] r=0 lpr=939 pi=[936,939)/1 crt=925'1465 lcod 925'1464 mlcod 0'0 activating+undersized+degraded mbc={}] state<Started/Primary/Active>: Activate Finished

PG reached active+clean at 2026-08-04T07:19:00

2026-08-04T07:19:00.514+0000 7f9eaa478640 10 osd.5 pg_epoch: 943 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=942/943 n=1401 ec=923/923 lis/c=942/942 les/c/f=943/943/0 sis=942) [5,79,44] r=0 lpr=942 crt=925'1465 lcod 925'1464 mlcod 0'0 active+clean] PeeringState::share_pg_info share_pg_info
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 943 get_con_osd_cluster to osd.44 from_epoch 943
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 943 get_nextmap_reserved map_reservations: {943=1}
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 943 release_map epoch: 943
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 943 get_con_osd_cluster to osd.79 from_epoch 943
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 943 get_nextmap_reserved map_reservations: {943=1}
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 943 release_map epoch: 943
2026-08-04T07:19:00.514+0000 7f9eaa478640 20 osd.5 pg_epoch: 943 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=942/943 n=1401 ec=923/923 lis/c=942/942 les/c/f=943/943/0 sis=942) [5,79,44] r=0 lpr=942 crt=925'1465 lcod 925'1464 mlcod 0'0 active+clean] PeeringState::prepare_stats_for_publish reporting purged_snaps []
2026-08-04T07:19:00.514+0000 7f9eaa478640 15 osd.5 pg_epoch: 943 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=942/943 n=1401 ec=923/923 lis/c=942/942 les/c/f=943/943/0 sis=942) [5,79,44] r=0 lpr=942 crt=925'1465 lcod 925'1464 mlcod 0'0 active+clean] PeeringState::prepare_stats_for_publish publish_stats_to_osd 943:4378
2026-08-04T07:19:00.514+0000 7f9eaa478640 10 osd.5 pg_epoch: 943 pg[10.0( v 925'1465 (0'0,925'1465] local-lis/les=942/943 n=1401 ec=923/923 lis/c=942/942 les/c/f=943/943/0 sis=942) [5,79,44] r=0 lpr=942 crt=925'1465 lcod 925'1464 mlcod 0'0 active+clean] scrubber<NotActive>: on_primary_active_clean: reg state: not-registered
2026-08-04T07:19:00.514+0000 7f9eaa478640 20  scrubberFSM  event: --vvvv---- PrimaryActivate

A corresponding "rebuild-stats: recorded" is not observed in the logs even though the
OSD successfully finished recovery on PG 10.0. This can mean that the latch start time
was reset mid-rebuild due to a bug.

Additionally, the min/max counters are not accurate and don't correlate with the pg_rebuild_counter.
For e.g.:

"pg_rebuild_duration": {
            "avgcount": 8,
            "sum": 77.587215665,
            "avgtime": 9.698401958
        },
        "pg_rebuild_max_secs": 30,
        "pg_rebuild_min_secs": 30
    },

Related issues 2 (0 open — 2 closed)

Copied to RADOS - Backport #79400: tentacle: [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate.ResolvedSridhar Seshasayee

Actions
Copied to RADOS - Backport #79401: umbrella: [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate.ResolvedSridhar Seshasayee

Actions

SS Updated by Sridhar Seshasayee 4 months ago Actions #1

  • Status changed from In Progress to Fix Under Review
  • Backport set to umbrella, tentacle
  • Pull request ID set to 70835

SS Updated by Sridhar Seshasayee 4 months ago Actions #2

  • Subject changed from [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state. to [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate.
  • Description updated (diff)

SS Updated by Sridhar Seshasayee 4 months ago · Edited Actions #3

Test Results With Fix

Tested a recovery/backfill scenario on a node with 8 OSDs and with EC4+2 profile.

Failure Sceenario: Brought down 2 OSDs within 30 secs of each other by setting
their CRUSH weights to 0. Logs were captured until all the PGs recovered.

Validation Mechanism:
The logs were parsed for the "rebuild-stats: latched" and a corresponding
"rebuild-stats: recorded" for the rebuild start and end confirmation
respectively.

Any "latched" message not having a corresponding "recorded" log means that
the PG undergoing the rebuild underwent a primary OSD handoff and the
rebuild was tracked by the new OSD. In other words, this is considered an
"orphaned latch" and is sometimes expected.

The number of rebuilds from the logs are correlated with the cumulative
counts of rebuilds captured by the perf counters on each OSD. Ideally
the counts from the logs and the perf counters should match.

NOTE:
For the test, the "latched" and the "recorded" log message levels were
reduced to 1 (from 15) in order to reduce the noise and ensure only the
important events are captured for validation.

Number of PGs configured = 273 (256 data + 16 meta data + 1 default)

Actual Results:
282 (perf-dump) = 285 (log-parsed latch records)

But 3 PGs displayed "orphaned latch" effect discussed below and so the
actual count is 282 which is perfect, no other residual gap was found.

Perf Dump Summary:

$ sudo ceph daemon osd.0 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 34,
            "sum": 10116.760008193,
            "avgtime": 297.551764946
        }
    },
$ sudo ceph daemon osd.1 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 34,
            "sum": 9488.300316428,
            "avgtime": 279.067656365
        }
    },
$ sudo ceph daemon osd.2 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 31,
            "sum": 5488.381140210,
            "avgtime": 177.044552910
        }
    },
$ sudo ceph daemon osd.3 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 34,
            "sum": 14493.655116432,
            "avgtime": 426.283974012
        }
    },
$ sudo ceph daemon osd.4 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 33,
            "sum": 4456.657439839,
            "avgtime": 135.050225449
        }
    },
$ sudo ceph daemon osd.5 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 35,
            "sum": 14505.430130480,
            "avgtime": 414.440860870
        }
    },
$ sudo ceph daemon osd.6 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 44,
            "sum": 8640.759022350,
            "avgtime": 196.380886871
        }
    },
$ sudo ceph daemon osd.7 perf dump | grep pg_rebuild* -A 5
        "pg_rebuild_duration": {
            "avgcount": 37,
            "sum": 15020.420084827,
            "avgtime": 405.957299589
        }
    },

The total rebuild count from all the above OSDs above comes to 282.

Of the 282 rebuilds recorded,
- 218 PGs had one rebuild episode
- 32 PGs had 2 rebuild episodes for a total of 64 rebuild episodes
The above gives us a total rebuild count of 282 rebuilds.

The 3 orphaned latches (285 latched, 282 recorded) — checked directly from the logs.
All three latches never got a recorded line. The logs for these are shown below:

osd.0 / pg 1.0: latches at 04:56:33.417. At 04:56:34.357 — under a second later — acting_primary 0 -> 7, role 0 -> 1.
osd.0 genuinely loses primary status.

2026-08-10T04:56:34.357+0000 7fed3ff3d640  1 osd.0 pg_epoch: 16 pg[1.0( v 12'132 (0'0,12'132] local-lis/les=14/15 n=2 ec=9/9 lis/c=14/11 les/c/f=15/12/0 sis=16 pruub=15.357557297s) [7,0,2] async=[7] r=1 lpr=16 pi=[11,16)/1 crt=12'132 lcod 12'131 active pruub 27.115552902s@ mbc={255={}}] PeeringState::start_peering_interval up [7,0,2] -> [7,0,2], acting [0,2] -> [7,0,2], acting_primary 0 -> 7, up_primary 7 -> 7, role 0 -> 1, features acting 4546383823830384639 upacting 4546383823830384639
2026-08-10T04:56:34.357+0000 7fed3ff3d640  1 osd.0 pg_epoch: 16 pg[1.0( v 12'132 (0'0,12'132] local-lis/les=14/15 n=2 ec=9/9 lis/c=14/11 les/c/f=15/12/0 sis=16 pruub=15.357483864s) [7,0,2] r=1 lpr=16 pi=[11,16)/1 crt=12'132 lcod 12'131 unknown NOTIFY pruub 27.115552902s@ mbc={}] state<Start>: transitioning to Stray

osd.1 / pg 3.70: latches at 04:59:04.518, having just become primary at 04:59:03.515. At 04:59:05.528 — about a second
later — acting_primary 1 -> 7, hands primary back off.

2026-08-10T04:59:04.518+0000 7f59901e8640  1 osd.1 pg_epoch: 41 pg[3.70s1( v 38'217 (0'0,38'217] local-lis/les=40/41 n=54 ec=28/28 lis/c=28/28 les/c/f=29/29/0 sis=40) [7,1,6,5,4,2]/[NONE,1,6,5,4,2]p1(1) async=[7(0)] r=1 lpr=40 pi=[28,40)/1 crt=38'217 mlcod 0'0 activating+undersized+degraded+remapped mbc={0={(0+0)=54},1={(1+0)=54},2={(1+0)=54},3={(1+0)=54},4={(1+0)=54},5={(1+0)=54}}] PeeringState::prepare_stats_for_publish rebuild-stats: latched failure start for 3.70s1 at 2026-08-10T04:59:04.518903+0000

...

2026-08-10T04:59:05.528+0000 7f59901e8640  1 osd.1 pg_epoch: 42 pg[3.70s1( v 41'219 (0'0,41'219] local-lis/les=40/41 n=55 ec=28/28 lis/c=40/28 les/c/f=41/29/0 sis=42 pruub=15.004616737s) [7,1,6,5,4,2]p7(0) async=[7(0)] r=1 lpr=42 pi=[28,42)/1 crt=41'219 lcod 41'218 active pruub 176.764801025s@ mbc={0={},1={},2={},3={},4={},5={}}] PeeringState::start_peering_interval up [7,1,6,5,4,2] -> [7,1,6,5,4,2], acting [2147483647,1,6,5,4,2] -> [7,1,6,5,4,2], acting_primary 1(1) -> 7, up_primary 7(0) -> 7, role 1 -> 1, features acting 4546383823830384639 upacting 4546383823830384639

osd.2 / pg 3.3d: identical shape, same ~1-second window, same handoff-away pattern.

2026-08-10T04:59:04.522+0000 7f580a29c640  1 osd.2 pg_epoch: 41 pg[3.3ds1( v 38'184 (0'0,38'184] local-lis/les=40/41 n=48 ec=28/28 lis/c=28/28 les/c/f=29/29/0 sis=40) [7,2,1,3,4,6]/[NONE,2,1,3,4,6]p2(1) async=[7(0)] r=1 lpr=40 pi=[28,40)/1 crt=38'184 mlcod 0'0 activating+undersized+degraded+remapped mbc={0={(0+0)=48},1={(1+0)=48},2={(1+0)=48},3={(1+0)=48},4={(1+0)=48},5={(1+0)=48}}] PeeringState::prepare_stats_for_publish rebuild-stats: latched failure start for 3.3ds1 at 2026-08-10T04:59:04.522956+0000

...

2026-08-10T04:59:06.531+0000 7f580e2a4640  1 osd.2 pg_epoch: 43 pg[3.3ds1( v 38'184 (0'0,38'184] local-lis/les=40/41 n=48 ec=28/28 lis/c=40/28 les/c/f=41/29/0 sis=43 pruub=13.992678642s) [7,2,1,3,4,6]p7(0) async=[7(0)] r=1 lpr=43 pi=[28,43)/1 crt=38'184 active pruub 175.475051880s@ mbc={0={},1={},2={},3={},4={},5={}}] PeeringState::start_peering_interval up [7,2,1,3,4,6] -> [7,2,1,3,4,6], acting [2147483647,2,1,3,4,6] -> [7,2,1,3,4,6], acting_primary 2(1) -> 7, up_primary 7(0) -> 7, role 1 -> 1, features acting 4546383823830384639 upacting 4546383823830384639

All three are genuine, real primary handovers landing within ~1 second of the latch.
Per the fix, start_peering_interval() correctly and silently clears the latch in this
case (!(was_old_primary && is_primary())) — but that clear happens in a different
function than the two diagnostic lines live in, so it produces no log trace. Not a bug,
not "still in progress" — just a code path the two log lines don't cover.

Conclusion
No evidence of a PeeringState.cc bug. Every discrepancy resolves (3 shown above) to the
already understood, non-code causes — real handovers silently (and correctly) clearing
latches outside the diagnostic lines' coverage, PeeringState.cc's own counters remain
internally perfect: every latch either resolves to a record or is fully
explained by a subsequent genuine handover, and the record total matches perf dump exactly
and therefore validates that the fix is working as expected.

KS Updated by Kamoltat (Junior) Sirivadhna 4 months ago Actions #4

Scrub: PR is raised @Sridhar Seshasayee I saw you ran some teuthology tests, was the tests approved?

SS Updated by Sridhar Seshasayee 4 months ago Actions #5

  • Status changed from Fix Under Review to Pending Backport

UB Updated by Upkeep Bot 4 months ago Actions #6

  • Merge Commit set to 83cf4c1aa67c3eee1fd413ea7e4ea421369755b0
  • Fixed In set to v21.3.0-1945-g83cf4c1aa6
  • Upkeep Timestamp set to 2026-08-12T01:36:18+00:00

SS Updated by Sridhar Seshasayee 4 months ago Actions #7

Kamoltat (Junior) Sirivadhna wrote in #note-4:

Scrub: PR is raised @Sridhar Seshasayee I saw you ran some teuthology tests, was the tests approved?

@Kamoltat (Junior) Sirivadhna Yes, in the interests of time, I ran my own teuthology test and it was good with
no related failures. Please see PR for the teuthology results information.

UB Updated by Upkeep Bot 4 months ago Actions #8

  • Copied to Backport #79400: tentacle: [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate. added

UB Updated by Upkeep Bot 4 months ago Actions #9

  • Copied to Backport #79401: umbrella: [pg_rebuild_stats]: Rebuild counters are not updated when PG enters degraded, undersized state and min/max counters are inaccurate. added

UB Updated by Upkeep Bot 4 months ago Actions #10

  • Tags (freeform) set to backport_processed

UB Updated by Upkeep Bot 3 months ago Actions #11

  • Status changed from Pending Backport to Backporting
  • Tags (freeform) deleted (backport_processed)
  • Upkeep Timestamp changed from 2026-08-12T01:36:18+00:00 to 2026-08-27T18:45:09+00:00

UB Updated by Upkeep Bot 2 months ago Actions #12

  • Status changed from Backporting to Resolved
  • Upkeep Timestamp changed from 2026-08-27T18:45:09+00:00 to 2026-09-29T13:06:29+00:00
Actions

Also available in: PDF Atom