Skip to content

osd/ECBackend: fix iterator invalidation in omap_get - #70142

Merged
SrinivasaBharath merged 1 commit into
ceph:mainfrom
sunyuechi:fix-ec-omap-iterator-invalidation
Jul 21, 2026
Merged

SrinivasaBharath merged 1 commit into
ceph:mainfrom
sunyuechi:fix-ec-omap-iterator-invalidation

Conversation

@sunyuechi

@sunyuechi sunyuechi commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

The removed_ranges erase loop in omap_get() calls
erase(out_it->first), which invalidates out_it, then does ++out_it
on the dead iterator, undefined behaviour. When adjacent keys are erased
this skips keys that should have been removed:

    Expected: { "k01", "k05", "k06" }
    Actual:   { "k01", "k03", "k05", "k06" }

The loop is extracted into a static remove_keys_in_ranges() helper so
it can be unit tested without an ObjectStore. The fix erases by iterator
and advances via erase()'s return value.

Fixes: https://tracker.ceph.com/issues/78177

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)

@sunyuechi
sunyuechi requested a review from a team as a code owner July 12, 2026 17:43
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

16 similar comments
@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@ceph-jenkins

Copy link
Copy Markdown
Collaborator

Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run.

@sunyuechi sunyuechi closed this Jul 12, 2026
@sunyuechi sunyuechi reopened this Jul 12, 2026
@sunyuechi
sunyuechi force-pushed the fix-ec-omap-iterator-invalidation branch from 0c4e7e3 to efec034 Compare July 12, 2026 19:44
@tchaikov

Copy link
Copy Markdown
Contributor

ok to test

@tchaikov
tchaikov force-pushed the fix-ec-omap-iterator-invalidation branch from efec034 to ec3df8a Compare July 13, 2026 03:08
Comment thread src/test/osd/test_ec_omap_journal.cc Resolved
Comment thread src/test/osd/test_ec_omap_journal.cc Resolved
Comment thread src/osd/ECBackend.cc Resolved
@sunyuechi
sunyuechi force-pushed the fix-ec-omap-iterator-invalidation branch from ec3df8a to 1cccd31 Compare July 13, 2026 05:14
@tchaikov

Copy link
Copy Markdown
Contributor

@sunyuechi could you keep the Fixes: https://tracker.ceph.com/issues/78177 tag in the commit message. as it's a fix not a cleanup. and we need to backport it to umbrella.

The removed_ranges erase loop in omap_get() called erase(out_it->first),
which invalidates out_it, then did ++out_it on the dead iterator (UB).
When adjacent keys were erased this skipped keys that should have been
removed:

    Expected: { "k01", "k05", "k06" }
    Actual:   { "k01", "k03", "k05", "k06" }

Extract the loop into a static remove_keys_in_ranges() helper so it can
be unit tested without an ObjectStore, and rewrite it as a range erase:
removed_ranges is a sorted map of non-overlapping [start, end) ranges.

Fixes: https://tracker.ceph.com/issues/78177
Signed-off-by: Sun Yuechi <[email protected]>
@sunyuechi
sunyuechi force-pushed the fix-ec-omap-iterator-invalidation branch from 1cccd31 to 1dd8cb8 Compare July 13, 2026 06:45
@sunyuechi

Copy link
Copy Markdown
Contributor Author

@tchaikov Thank you for your help. Updated.

@tchaikov tchaikov 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

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by skanta started 2026-07-15-06:32.

@SrinivasaBharath

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by skanta started 2026-07-17-04:58.

@NitzanMordhai

Copy link
Copy Markdown
Contributor

@SrinivasaBharath
SrinivasaBharath merged commit d200375 into ceph:main Jul 21, 2026
6 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.

6 participants