Skip to content

osd: Fix condition for rolling forward pg log entries - #68888

Merged
MattyWilliams22 merged 1 commit into
ceph:mainfrom
MattyWilliams22:mw-peering-state-rollforward
Jun 10, 2026
Merged

MattyWilliams22 merged 1 commit into
ceph:mainfrom
MattyWilliams22:mw-peering-state-rollforward

Conversation

@MattyWilliams22

@MattyWilliams22 MattyWilliams22 commented May 13, 2026 •

Copy link
Copy Markdown
Contributor

https://tracker.ceph.com/issues/76577

This PR fixes a critical bug where writes to backfilling shards (those not in the acting set) below the last_backfill watermark were failing to roll forward. This issue previously caused silent storage leaks (generation'd objects not being cleaned up), but with the introduction of omap support in EC pools, skipping the roll forward would result in dropped omap updates and severe data integrity issues.

The condition has been updated to check whether the shard is in the acting set. By explicitly checking !is_acting(pg_whoami), we ensure that updates to backfilling shards (which are not in the acting set) are properly rolled forward as soon as they are applied.

It is safe to roll forward updates to shards that are not in the acting set as soon as they are applied because these shards are not used by Peering when determining the authoritative log and they do not need to be read for recovery. The worst consequence of rolling forward updates on these shards early is that if the update later gets rolled back the object will be marked as missing on this shard and will generate a little extra recovery work.

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.

@github-actions github-actions Bot added the core label May 13, 2026
@djgalloway

Copy link
Copy Markdown
Contributor

jenkins test pr

@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@MattyWilliams22 MattyWilliams22 self-assigned this May 14, 2026
@MattyWilliams22
MattyWilliams22 force-pushed the mw-peering-state-rollforward branch from c1cfd97 to 026d460 Compare May 14, 2026 12:44
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

@MattyWilliams22
MattyWilliams22 marked this pull request as ready for review May 15, 2026 15:30
@MattyWilliams22
MattyWilliams22 requested a review from a team as a code owner May 15, 2026 15:30

@aainscow aainscow left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bill-scales bill-scales left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approve - can you look at tidying up the dout statement

Comment thread src/osd/PeeringState.cc Resolved
Comment thread src/osd/PeeringState.cc
* above */
if (transaction_applied &&
p->soid > info.last_backfill) {
if (transaction_applied && !is_acting(pg_whoami)) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK: This change deserves some explanation

The old test "if (transaction_applied &&p->soid > info.last_backfill)" didn't work:

For EC pools transaction_applied = !op.backfill_or_async_recovery = should_send

PrimaryLogPG::should_send_op
  bool should_send =
      hoid.pool != (int64_t)info.pgid.pool() ||
      hoid <= last_backfill_started ||
      hoid <= recovery_state.get_peer_info(peer).last_backfill;

So the old test could never be true for EC pools because the oid can't be <= and > than last_backfill at the same time.

For Replica pools transaction_applied = should_send on the replica shards, but strangely is always true on the primary shard (perhaps another bug?). However roll_forward is essentially a NOP for Replica pools so it doesn't really matter whether we try to roll forward or not.

The new test now aggressively rolls forward transactions to shards which are outside of the acting set (which means they must be backfilling or performing async_recovery). Rolling forward in these cases is safe because they won't be considered when determining last_update in a future peering cycle. Rolling forward in these cases is necessary because of the skip_rollforward case earlier in this function which will not only skip the new log entry but will skip any other entries that have a pending rollforward. By aggressively calling rollforward here we avoid log entries that we want to be rolled forward from being skipped.

@MattyWilliams22
MattyWilliams22 force-pushed the mw-peering-state-rollforward branch from 026d460 to f7d9e89 Compare May 19, 2026 15:12
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test windows

1 similar comment
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test windows

@amathuria

Copy link
Copy Markdown
Contributor

I was reviewing the QA test results for this PR and saw this issue that looks new in a thrash EC test:
https://pulpito.ceph.com/skanta-2026-06-02_04:58:02-rados-wip-bharath3-testing-2026-06-02-0837-distro-default-trial/253356

2026-06-02T07:24:08.710+0000 7f40209896c0 -1 /ceph/rpmbuild/BUILD/ceph-21.0.0-1914-ga8adeb5c/src/osd/PeeringState.cc: In function 'PeeringState::Crashed::Crashed(boost::statechart::state<PeeringState::Crashed, PeeringState::PeeringMachine>::my_context)' thread 7f40209896c0 time 2026-06-02T07:24:08.709731+0000
/ceph/rpmbuild/BUILD/ceph-21.0.0-1914-ga8adeb5c/src/osd/PeeringState.cc: 5264: ceph_abort_msg("we got a bad state machine event")

@MattyWilliams22 @bill-scales @aainscow could one of you take a look at the failure and let me know if it looks related to this PR?
Thanks!

@bill-scales

Copy link
Copy Markdown
Contributor

I was reviewing the QA test results for this PR and saw this issue that looks new in a thrash EC test: https://pulpito.ceph.com/skanta-2026-06-02_04:58:02-rados-wip-bharath3-testing-2026-06-02-0837-distro-default-trial/253356

2026-06-02T07:24:08.710+0000 7f40209896c0 -1 /ceph/rpmbuild/BUILD/ceph-21.0.0-1914-ga8adeb5c/src/osd/PeeringState.cc: In function 'PeeringState::Crashed::Crashed(boost::statechart::state<PeeringState::Crashed, PeeringState::PeeringMachine>::my_context)' thread 7f40209896c0 time 2026-06-02T07:24:08.709731+0000
/ceph/rpmbuild/BUILD/ceph-21.0.0-1914-ga8adeb5c/src/osd/PeeringState.cc: 5264: ceph_abort_msg("we got a bad state machine event")

@MattyWilliams22 @bill-scales @aainscow could one of you take a look at the failure and let me know if it looks related to this PR? Thanks!

@amathuria This is not related to this PR, its a base code issue in the PeeringStateMachine concerning reservations for backfill - this part of the state machine has many race hazards. I've opened https://tracker.ceph.com/issues/77096

@amathuria

Copy link
Copy Markdown
Contributor

I was reviewing the QA test results for this PR and saw this issue that looks new in a thrash EC test: https://pulpito.ceph.com/skanta-2026-06-02_04:58:02-rados-wip-bharath3-testing-2026-06-02-0837-distro-default-trial/253356

2026-06-02T07:24:08.710+0000 7f40209896c0 -1 /ceph/rpmbuild/BUILD/ceph-21.0.0-1914-ga8adeb5c/src/osd/PeeringState.cc: In function 'PeeringState::Crashed::Crashed(boost::statechart::state<PeeringState::Crashed, PeeringState::PeeringMachine>::my_context)' thread 7f40209896c0 time 2026-06-02T07:24:08.709731+0000
/ceph/rpmbuild/BUILD/ceph-21.0.0-1914-ga8adeb5c/src/osd/PeeringState.cc: 5264: ceph_abort_msg("we got a bad state machine event")

@MattyWilliams22 @bill-scales @aainscow could one of you take a look at the failure and let me know if it looks related to this PR? Thanks!

@amathuria This is not related to this PR, its a base code issue in the PeeringStateMachine concerning reservations for backfill - this part of the state machine has many race hazards. I've opened https://tracker.ceph.com/issues/77096

@bill-scales Thanks for checking and opening the tracker! I'll update the QA run review

@amathuria

Copy link
Copy Markdown
Contributor

@MattyWilliams22
MattyWilliams22 force-pushed the mw-peering-state-rollforward branch from f7d9e89 to ec7afb5 Compare June 4, 2026 15:34
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test api

1 similar comment
@MattyWilliams22

Copy link
Copy Markdown
Contributor Author

jenkins test api

@bill-scales bill-scales left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Additional bug fix is to invalidate pwlc if the shard doing backfill/async recovery rolls forward the log entry as it is appended to the log. This ensures that these shards do not have pwlc that is ahead of the last completed write I/O.

It is safe to do this for the same reasons as it was safe to do it when the roll forward was skipped (lines 4809-4819).

@ljflores

ljflores commented Jun 10, 2026 •

Copy link
Copy Markdown
Member

@MattyWilliams22
MattyWilliams22 merged commit 8b35fcb into ceph:main Jun 10, 2026
6 checks passed
@MattyWilliams22
MattyWilliams22 deleted the mw-peering-state-rollforward branch June 10, 2026 15:20
@MattyWilliams22
MattyWilliams22 restored the mw-peering-state-rollforward branch July 20, 2026 14:32
@MattyWilliams22
MattyWilliams22 deleted the mw-peering-state-rollforward branch September 18, 2026 08:40
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.

7 participants