Skip to content

osd: Allow multiple objects with same version in missing list. - #68284

Merged
aainscow merged 1 commit into
ceph:mainfrom
aainscow:rmissing_second_fix
May 1, 2026
Merged

aainscow merged 1 commit into
ceph:mainfrom
aainscow:rmissing_second_fix

Conversation

@aainscow

@aainscow aainscow commented Apr 9, 2026

Copy link
Copy Markdown
Contributor

Most of the time, a single version in a PG can only correspond to a single object.

However, following a PG merge it is possible, even likely, that two objects will
have the same version. The PG Log works around this by discarding the log.

However, during backfill, it is possible for the missing list to be build with
these duplicate versions.

A recently added assert detected that this scenario was corrupting the reverse
missing list (rmissing). This behaviour has always existed, but was previously
unnoticed. It could cause some bugs and potentially loop-asserts on OSDs,
although mostly would not be noticed.

Here we fix this properly, by converting rmissing to a multimap. This is wrapped
in some insert functions, which assert that the rmissing list does not end up
with duplicate entries. The code is optimised for the case where there are no
duplicate versions.

Additionally, some of the old asserts have been rolled into the insert functions.

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

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.

@aainscow
aainscow requested a review from a team as a code owner April 9, 2026 13:44
@aainscow
aainscow force-pushed the rmissing_second_fix branch 4 times, most recently from d9ea30a to 6b98146 Compare April 10, 2026 09:00
@aainscow
aainscow requested review from Matan-B and bill-scales April 10, 2026 13:26
@aainscow
aainscow force-pushed the rmissing_second_fix branch from 6b98146 to 38d3734 Compare April 10, 2026 13:38

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

  • Crimson code doesn't compile
  • I think rmissing_insert_allow_duplicate_version should be idempotent
  • I'm not a fan of having insert/insert_allow_duplicate_version and add/add_allow_duplicate_version. I think you'll get more bugs from the wrong version being called than you'll get protection from worrying about the missing list having different objects with the same version. As a case in point I think PeeringState::force_object_missing is using the wrong version of add.

Comment thread src/crimson/osd/pg_recovery.cc Resolved
Comment thread src/osd/osd_types.h Resolved
Comment thread src/osd/osd_types.h Resolved
Comment thread src/osd/osd_types.h Outdated
if (it != rmissing.end() && it->first == version) {
auto range = rmissing.equal_range(version);
for (auto check_it = range.first; check_it != range.second; ++check_it) {
ceph_assert(check_it->second != object); // Duplicate OID not allowed

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.

Previously the code was idempotent and allowed the same {version,oid} to be inserted multiple times. I think you want to change this to just skip the insert (don't want multiple identical entries in the multimap) rather than assert

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Fixed

Comment thread src/osd/osd_types.h Outdated
}

// Insert a version-to-object mapping.
void rmissing_insert(

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.

I'm not a fan of having rmissing_insert and rmissing_insert_allow_duplicate_version. I don't think the extra assert is worth the risk of calling the wrong version of the function. It's not easy to work out whether the missing object that is being updated has a log entry (and hence must not have a duplicate version) or doesn't (in which case you must allow for duplicate entries).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agreed - I have removed rmissing_insert_allow_duplicate_version and moved its functionality to rmissing_insert

Comment thread src/osd/osd_types.h Resolved
Comment thread src/osd/PrimaryLogPG.cc Resolved
Comment thread src/osd/osd_types.h Resolved
@aainscow
aainscow force-pushed the rmissing_second_fix branch from 38d3734 to db41803 Compare April 13, 2026 20:08
@aainscow
aainscow requested a review from bill-scales April 14, 2026 09:37
Comment thread src/osd/osd_types.h Resolved
Comment thread src/osd/osd_types.h
ChangeTracker<TrackChanges> tracker;
private:
// Private wrapper functions for rmissing manipulation
// These ensure rmissing can only be modified through controlled interfaces

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.

nit: Comment is misleading - rmissing is public, it just so happens that only methods in this class insert and erase entries from rmissing.

Most of the time, a single version in a PG can only correspond to a single object.

However, following a PG merge it is possible, even likely, that two objects will
have the same version.   The PG Log works around this by discarding the log.

However, during backfill, it is possible for the missing list to be build with
these duplicate versions.

A recently added assert detected that this scenario was corrupting the reverse
missing list (rmissing). This behaviour has always existed, but was previously
unnoticed.  It could cause some bugs and potentially loop-asserts on OSDs,
although mostly would not be noticed.

Here we fix this properly, by converting rmissing to a multimap. This is wrapped
in some insert functions, which assert that the rmissing list does not end up
with duplicate entries.  The code is optimised for the case where there are no
duplicate versions.

Additionally, some of the old asserts have been rolled into the insert functions.

Fixes: https://tracker.ceph.com/issues/75778
Signed-off-by: Alex Ainscow <[email protected]>
@aainscow
aainscow force-pushed the rmissing_second_fix branch from db41803 to f394040 Compare April 15, 2026 10:27

@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

@jdurgin jdurgin left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice addition of unit tests covering a range of edge cases and new behavior!

@aainscow
aainscow merged commit 2a23682 into ceph:main May 1, 2026
6 checks passed
@aainscow aainscow added the backport-complete A backport was necessary, but all work has been completed. label Oct 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-complete A backport was necessary, but all work has been completed. core crimson needs-crimson-qa needs-qa tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants