Skip to content

osd: Improve debug for PeeringState state machine crashes - #72229

Merged
bill-scales merged 1 commit into
ceph:mainfrom
bill-scales:psdebug
Oct 27, 2026
Merged

bill-scales merged 1 commit into
ceph:mainfrom
bill-scales:psdebug

Conversation

@bill-scales

@bill-scales bill-scales commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Currently when the PeeringState state machine crashes because of an invalid state transition it provides no debug about which state it was previously in or the stimulus that caused the crash. Add this information to the abort message.

The state machine is hierarchical, make sure that we capture the innermost state (which is exited first) rather than the outermost state (which is exited last) before entering the crashed state.


Here's a test to show what the new output looks like using adeliberate bug to cause a peering state machine crash when local recovery reservations are acquired:

--- a/src/osd/PeeringState.h
+++ b/src/osd/PeeringState.h
@@ -1222,7 +1222,7 @@ public:

struct WaitLocalRecoveryReserved : boost::statechart::state< WaitLocalRecoveryReserved, Active >, NamedState {
typedef boost::mpl::list <

  •  boost::statechart::transition< LocalRecoveryReserved, WaitRemoteRecoveryReserved >,
    
  •  //BUG!      boost::statechart::transition< LocalRecoveryReserved, WaitRemoteRecoveryReserved >,
     boost::statechart::custom_reaction< RecoveryTooFull >
     > reactions;
    
    explicit WaitLocalRecoveryReserved(my_context ctx);

Procedure to cause a crash with this state transition:

Start cluster
Take one osd down
Create object with rados put
Bring osd up, PG will try and recover

New assert:

/ceph/src/osd/PeeringState.cc: 5445: ceph_abort_msg("bad state machine event in state 'Started/Primary/Active/WaitLocalRecoveryReserved': epoch_sent: 31 epoch_requested: 31 LocalRecoveryReserved")
The new assert shows the previous state and the stimulus that caused the state machine to crash

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.

@bill-scales
bill-scales requested a review from a team as a code owner September 30, 2026 09:03
@github-actions github-actions Bot added the core label Sep 30, 2026
Comment thread src/osd/PeeringState.cc Resolved
@bill-scales
bill-scales requested a review from adam-lj September 30, 2026 09:08
Currently when the PeeringState machine crashes because of an
invalid state transition it provides no debug about which state
it was previously in or the stimulus that caused the crash. Add
this information to the abort message.

Record the state and stimulus in handle_event because
1) It is a hiearchical state machine and we want to capture the
innermost state, not the intermediate transitions as we exit
all the way to the outermost state before entering Crashed

2) Similarly if the state machine issues post_event's to
make further transitions we don't want to record these
intermediate states.

Signed-off-by: Bill Scales <[email protected]>
Assisted-by: IBM Bob 2.2.0
@bill-scales

Copy link
Copy Markdown
Contributor Author

Made changes suggested by Adam & Claude - simplify logic by capturing the last state in handle_event and use ceph_demangle to produce slightly more readable events.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to wip-bharath20-testing-20261002.224634-main.

@adam-lj

adam-lj commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

@bill-scales
bill-scales merged commit 86c0b88 into ceph:main Oct 27, 2026
16 checks passed
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.

3 participants