Skip to content

osd: add last_degraded field to pg_stat_t - #68910

Merged
sseshasa merged 1 commit into
ceph:mainfrom
sseshasa:wip-osd-perf-counters-for-durability-score
Jun 5, 2026
Merged

sseshasa merged 1 commit into
ceph:mainfrom
sseshasa:wip-osd-perf-counters-for-durability-score

Conversation

@sseshasa

@sseshasa sseshasa commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Introduce a 'last_degraded' timestamp to the pg_stat_t structure to track the initial point of redundancy loss. This field, used in conjunction with 'last_clean', allows the manager to calculate a cluster-wide durability score (needs a separate effort) by measuring the duration of vulnerability windows.

Changes:

  1. Add last_degraded (utime_t) to pg_stat_t in osd_types.h.
  2. Increment pg_stat_t encoding version to 31. The decode logic defaults last_degraded to last_clean for backward compatibility during rolling upgrades.
  3. Update operator==, dump(), and generate_test_instances() to
    support ceph-dencoder testing and JSON output.
  4. Implement latching logic in PeeringState::prepare_stats_for_publish():
    • A PG is considered vulnerable if in DEGRADED or UNDERSIZED state.
    • last_degraded is set to 'now' only if it is <= last_clean, effectively latching the timestamp to the start of the failure event until the PG next becomes clean.
  5. Standalone tests to verify:
    • The last_degraded timestamp latching logic.
    • Verify last_degraded timestamp is modified when OSDs are marked 'out' for draining purposes in which case PGs are marked undersized.

Fixes: https://tracker.ceph.com/issues/76604
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 x between the brackets: [x]. Spaces and capitalization matter when checking off items this way.

Checklist

  • Tracker (select at least one)
    • References tracker ticket
    • Very recent bug; references commit where it was introduced
    • New feature (ticket optional)
    • Doc update (no ticket needed)
    • Code cleanup (no ticket needed)
  • Component impact
    • Affects Dashboard, opened tracker ticket
    • Affects Orchestrator, opened tracker ticket
    • No impact that needs to be tracked
  • Documentation (select at least one)
    • Updates relevant documentation
    • No doc update is appropriate
  • Tests (select at least one)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

@sseshasa
sseshasa requested review from pdvian and rzarzynski May 14, 2026 14:06
@sseshasa
sseshasa requested a review from a team as a code owner May 14, 2026 14:06
@sseshasa

sseshasa commented May 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Testing With ceph-dencode (older version) and decode using latest ceph-dencoder with ‘last_degraded’ field in pg_stat_t

Create encoding of the 3 instances of pg_stat_t using an older ceph-dencoder binary

sudo /usr/bin/ceph-dencoder type pg_stat_t select_test 1 encode export ~/tmp/pg_stat_instance_1.bin
sudo /usr/bin/ceph-dencoder type pg_stat_t select_test 2 encode export ~/tmp/pg_stat_instance_2.bin
sudo /usr/bin/ceph-dencoder type pg_stat_t select_test 3 encode export ~/tmp/pg_stat_instance_3.bin

Testing Outcome:
Confirm that the ‘last_degraded’ field is present in the JSON output when the new ceph-dencoder binary created with the ‘last_degraded’ field introduced. Additionally, confirm that the value of ‘last_degraded’ == ‘last_clean’ as per the decoding logic:

Instance 1 Decode Result

$ ceph-dencoder type pg_stat_t import ~/tmp/pg_stat_instance_1.bin decode dump_json
{
   "version": "0'0",
   "reported_seq": 0,
   "reported_epoch": 0,
   "state": "unknown",
   "last_fresh": "0.000000",
   "last_change": "0.000000",
   "last_active": "0.000000",
   "last_peered": "0.000000",
   "last_clean": "0.000000",  <--
   "last_degraded": "0.000000", <--
   "last_became_active": "0.000000",
   "last_became_peered": "0.000000",
   "last_unstale": "0.000000",
   "last_undegraded": "0.000000",
   "last_fullsized": "0.000000",
   "mapping_epoch": 0,
   "log_start": "0'0",
   "ondisk_log_start": "0'0",
   "created": 0,
   "last_epoch_clean": 0,
   "parent": "0.0",
   "parent_split_bits": 0,
   "last_scrub": "0'0",
   "last_scrub_stamp": "0.000000",
   "last_deep_scrub": "0'0",
   "last_deep_scrub_stamp": "0.000000",
   "last_clean_scrub_stamp": "0.000000",
   "objects_scrubbed": 0,
   "log_size": 0,
   "log_dups_size": 0,
   "ondisk_log_size": 0,
   "stats_invalid": false,
   "dirty_stats_invalid": false,
   "omap_stats_invalid": false,
   "hitset_stats_invalid": false,
   "hitset_bytes_stats_invalid": false,
   "pin_stats_invalid": false,
   "manifest_stats_invalid": false,
   "snaptrimq_len": 0,
   "last_scrub_duration": 0,
   "scrub_schedule": "--",
   "scrub_duration": 0,
   "objects_trimmed": 0,
   "snaptrim_duration": 0,
   "stat_sum": {
       "num_bytes": 0,
       "num_objects": 0,
       "num_object_clones": 0,
       "num_object_copies": 0,
       "num_objects_missing_on_primary": 0,
       "num_objects_missing": 0,
       "num_objects_degraded": 0,
       "num_objects_misplaced": 0,
       "num_objects_unfound": 0,
       "num_objects_dirty": 0,
       "num_whiteouts": 0,
       "num_read": 0,
       "num_read_kb": 0,
       "num_write": 0,
       "num_write_kb": 0,
       "num_scrub_errors": 0,
       "num_shallow_scrub_errors": 0,
       "num_deep_scrub_errors": 0,
       "num_objects_recovered": 0,
       "num_bytes_recovered": 0,
       "num_keys_recovered": 0,
       "num_objects_omap": 0,
       "num_objects_hit_set_archive": 0,
       "num_bytes_hit_set_archive": 0,
       "num_flush": 0,
       "num_flush_kb": 0,
       "num_evict": 0,
       "num_evict_kb": 0,
       "num_promote": 0,
       "num_flush_mode_high": 0,
       "num_flush_mode_low": 0,
       "num_evict_mode_some": 0,
       "num_evict_mode_full": 0,
       "num_objects_pinned": 0,
       "num_legacy_snapsets": 0,
       "num_large_omap_objects": 0,
       "num_objects_manifest": 0,
       "num_omap_bytes": 0,
       "num_omap_keys": 0,
       "num_objects_repaired": 0
   },
   "up": [],
   "acting": [],
   "avail_no_missing": [],
   "object_location_counts": [],
   "blocked_by": [],
   "up_primary": -1,
   "acting_primary": -1,
   "purged_snaps": []
}

Instance 2 Decode Result

$ ceph-dencoder type pg_stat_t import ~/tmp/pg_stat_instance_2.bin decode dump_json
{
   "version": "1'3",
   "reported_seq": 2,
   "reported_epoch": 1,
   "state": "creating+active+down+recovery_unfound+backfill_unfound",
   "last_fresh": "1002.000000",
   "last_change": "1002.000000",
   "last_active": "1002.000000",
   "last_peered": "0.000000",
   "last_clean": "1002.000000", <--
   "last_degraded": "1002.000000", <--
   "last_became_active": "0.000000",
   "last_became_peered": "0.000000",
   "last_unstale": "1002.000000",
   "last_undegraded": "1002.000000",
   "last_fullsized": "1002.000000",
   "mapping_epoch": 998,
   "log_start": "1'4",
   "ondisk_log_start": "1'5",
   "created": 6,
   "last_epoch_clean": 7,
   "parent": "2.1",
   "parent_split_bits": 12,
   "last_scrub": "9'10",
   "last_scrub_stamp": "11.000000",
   "last_deep_scrub": "13'14",
   "last_deep_scrub_stamp": "15.000000",
   "last_clean_scrub_stamp": "17.000000",
   "objects_scrubbed": 0,
   "log_size": 99,
   "log_dups_size": 0,
   "ondisk_log_size": 88,
   "stats_invalid": false,
   "dirty_stats_invalid": false,
   "omap_stats_invalid": false,
   "hitset_stats_invalid": false,
   "hitset_bytes_stats_invalid": false,
   "pin_stats_invalid": false,
   "manifest_stats_invalid": false,
   "snaptrimq_len": 1048576,
   "last_scrub_duration": 3617,
   "scrub_schedule": "--",
   "scrub_duration": 0.0030000000000000001,
   "objects_trimmed": 0,
   "snaptrim_duration": 0.123,
   "stat_sum": {
       "num_bytes": 1,
       "num_objects": 3,
       "num_object_clones": 4,
       "num_object_copies": 5,
       "num_objects_missing_on_primary": 6,
       "num_objects_missing": 123,
       "num_objects_degraded": 7,
       "num_objects_misplaced": 1232,
       "num_objects_unfound": 8,
       "num_objects_dirty": 21,
       "num_whiteouts": 22,
       "num_read": 9,
       "num_read_kb": 10,
       "num_write": 11,
       "num_write_kb": 12,
       "num_scrub_errors": 35,
       "num_shallow_scrub_errors": 18,
       "num_deep_scrub_errors": 17,
       "num_objects_recovered": 14,
       "num_bytes_recovered": 15,
       "num_keys_recovered": 16,
       "num_objects_omap": 0,
       "num_objects_hit_set_archive": 2,
       "num_bytes_hit_set_archive": 27,
       "num_flush": 5,
       "num_flush_kb": 6,
       "num_evict": 7,
       "num_evict_kb": 8,
       "num_promote": 9,
       "num_flush_mode_high": 0,
       "num_flush_mode_low": 1,
       "num_evict_mode_some": 1,
       "num_evict_mode_full": 0,
       "num_objects_pinned": 20,
       "num_legacy_snapsets": 0,
       "num_large_omap_objects": 5,
       "num_objects_manifest": 2,
       "num_omap_bytes": 20000,
       "num_omap_keys": 200,
       "num_objects_repaired": 300
   },
   "up": [
       123
   ],
   "acting": [
       456
   ],
   "avail_no_missing": [
       "456"
   ],
   "object_location_counts": [
       {
           "shards": "0,1",
           "objects": 10
       },
       {
           "shards": "0,1,2",
           "objects": 5
       }
   ],
   "blocked_by": [],
   "up_primary": 123,
   "acting_primary": 456,
   "purged_snaps": []
}

Instance 3 Decode Result

$ ceph-dencoder type pg_stat_t import ~/tmp/pg_stat_instance_3.bin decode dump_json
{
   "version": "1'3",
   "reported_seq": 2,
   "reported_epoch": 1,
   "state": "creating+active+down+recovery_unfound+backfill_unfound",
   "last_fresh": "1002.000000",
   "last_change": "1002.000000",
   "last_active": "1002.000000",
   "last_peered": "0.000000",
   "last_clean": "1002.000000", <--
   "last_degraded": "1002.000000", <--
   "last_became_active": "0.000000",
   "last_became_peered": "0.000000",
   "last_unstale": "1002.000000",
   "last_undegraded": "1002.000000",
   "last_fullsized": "1002.000000",
   "mapping_epoch": 998,
   "log_start": "1'4",
   "ondisk_log_start": "1'5",
   "created": 6,
   "last_epoch_clean": 7,
   "parent": "2.1",
   "parent_split_bits": 12,
   "last_scrub": "9'10",
   "last_scrub_stamp": "11.000000",
   "last_deep_scrub": "13'14",
   "last_deep_scrub_stamp": "15.000000",
   "last_clean_scrub_stamp": "17.000000",
   "objects_scrubbed": 0,
   "log_size": 99,
   "log_dups_size": 0,
   "ondisk_log_size": 88,
   "stats_invalid": false,
   "dirty_stats_invalid": false,
   "omap_stats_invalid": false,
   "hitset_stats_invalid": false,
   "hitset_bytes_stats_invalid": false,
   "pin_stats_invalid": false,
   "manifest_stats_invalid": false,
   "snaptrimq_len": 1048576,
   "last_scrub_duration": 3617,
   "scrub_schedule": "--",
   "scrub_duration": 0.0030000000000000001,
   "objects_trimmed": 0,
   "snaptrim_duration": 0.123,
   "stat_sum": {
       "num_bytes": 1,
       "num_objects": 3,
       "num_object_clones": 4,
       "num_object_copies": 5,
       "num_objects_missing_on_primary": 6,
       "num_objects_missing": 123,
       "num_objects_degraded": 7,
       "num_objects_misplaced": 1232,
       "num_objects_unfound": 8,
       "num_objects_dirty": 21,
       "num_whiteouts": 22,
       "num_read": 9,
       "num_read_kb": 10,
       "num_write": 11,
       "num_write_kb": 12,
       "num_scrub_errors": 35,
       "num_shallow_scrub_errors": 18,
       "num_deep_scrub_errors": 17,
       "num_objects_recovered": 14,
       "num_bytes_recovered": 15,
       "num_keys_recovered": 16,
       "num_objects_omap": 0,
       "num_objects_hit_set_archive": 2,
       "num_bytes_hit_set_archive": 27,
       "num_flush": 5,
       "num_flush_kb": 6,
       "num_evict": 7,
       "num_evict_kb": 8,
       "num_promote": 9,
       "num_flush_mode_high": 0,
       "num_flush_mode_low": 1,
       "num_evict_mode_some": 1,
       "num_evict_mode_full": 0,
       "num_objects_pinned": 20,
       "num_legacy_snapsets": 0,
       "num_large_omap_objects": 5,
       "num_objects_manifest": 2,
       "num_omap_bytes": 20000,
       "num_omap_keys": 200,
       "num_objects_repaired": 300
   },
   "up": [
       123,
       124
   ],
   "acting": [
       456,
       124
   ],
   "avail_no_missing": [
       "456"
   ],
   "object_location_counts": [
       {
           "shards": "0,1",
           "objects": 10
       },
       {
           "shards": "0,1,2",
           "objects": 5
       }
   ],
   "blocked_by": [
       155,
       156
   ],
   "up_primary": 124,
   "acting_primary": 124,
   "purged_snaps": []
}

Comment thread src/osd/osd_types.cc Resolved
Comment thread src/osd/osd_types.h Resolved
@sseshasa
sseshasa force-pushed the wip-osd-perf-counters-for-durability-score branch 2 times, most recently from 385dd5e to b2d9e19 Compare May 15, 2026 06:37
@sseshasa

Copy link
Copy Markdown
Contributor Author

The latest push just adds a release note for this change. No functional change is added.

@sseshasa
sseshasa force-pushed the wip-osd-perf-counters-for-durability-score branch from b2d9e19 to e5a95e3 Compare May 15, 2026 06:41
@sseshasa

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@github-actions

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@sseshasa
sseshasa force-pushed the wip-osd-perf-counters-for-durability-score branch from e5a95e3 to 7aab8df Compare May 20, 2026 07:02
@sseshasa

Copy link
Copy Markdown
Contributor Author

Latest push was a rebase to resolve a conflict in PendingReleaseNotes.

@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@amathuria

Copy link
Copy Markdown
Contributor

Introduce a 'last_degraded' timestamp to the pg_stat_t structure to track
the initial point of redundancy loss. This field, used in conjunction
with 'last_clean', allows the manager to calculate a cluster-wide
durability score by measuring the duration of vulnerability windows.

Changes:
1) Add last_degraded (utime_t) to pg_stat_t in osd_types.h.
2) Increment pg_stat_t encoding version to 31. The decode logic
   defaults last_degraded to last_clean for backward compatibility
   during rolling upgrades.
3) Update operator==, dump(), and generate_test_instances() to
   support ceph-dencoder testing and JSON output.
4) Implement latching logic in PeeringState::prepare_stats_for_publish():
   - A PG is considered vulnerable if in DEGRADED or UNDERSIZED state.
   - last_degraded is set to 'now' only if it is <= last_clean,
     effectively latching the timestamp to the start of the failure
     event until the PG next becomes clean.
5) Standalone tests to verify:
   - The last_degraded timestamp latching logic.
   - Verify last_degraded timestamp is modified when OSDs are marked 'out' for
     draining purposes in which case PGs are marked undersized.
6) Release note the addition of 'last_degraded' field to PG stats.

Fixes: https://tracker.ceph.com/issues/76604
Signed-off-by: Sridhar Seshasayee <[email protected]>
@sseshasa
sseshasa force-pushed the wip-osd-perf-counters-for-durability-score branch from 7aab8df to 252d149 Compare June 4, 2026 14:18
@sseshasa

sseshasa commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

Latest push was again a rebase to resolve a conflict in PendingReleaseNotes.

@sseshasa

sseshasa commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test api

1 similar comment
@sseshasa

sseshasa commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test api

@sseshasa
sseshasa merged commit 0fbcd19 into ceph:main Jun 5, 2026
6 checks passed
@sseshasa

sseshasa commented Jun 5, 2026

Copy link
Copy Markdown
Contributor Author

Merging based on teuthology tests (Approved). The failure in jenkins api tests is unrelated.

@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown

This is an automated message by src/script/redmine-upkeep.py.

I have resolved the following tracker ticket due to the merge of this PR:

No backports are pending for the ticket. If this is incorrect, please update the tracker
ticket and reset to Pending Backport state.

Update Log: https://github.com/ceph/ceph/actions/runs/27003949712

@sseshasa sseshasa added this to the umbrella milestone Jun 5, 2026
@sseshasa
sseshasa deleted the wip-osd-perf-counters-for-durability-score branch June 8, 2026 05:57
@batrick batrick modified the milestones: umbrella, v21.1.1 Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants