Skip to content

rgw: cls_timeindex: avoid dup ext key (object name) indexes - #60137

Merged
anrao19 merged 3 commits into
ceph:mainfrom
trociny:wip-68380
Nov 13, 2026
Merged

anrao19 merged 3 commits into
ceph:mainfrom
trociny:wip-68380

Conversation

@trociny

@trociny trociny commented Oct 5, 2024 •

Copy link
Copy Markdown
Contributor

The object expirer gets an expiration hint (a cls_timeindex entry keyed by
the expiration time and the object name) every time X-Delete-At/After is set
on an object. Updating it adds a new hint but leaves the old one, so stale
hints pile up in the obj_delete_at_hint.* omap.

Originally a stale hint was harmless: the expirer passed hint.exp_time to
RGWRados::delete_obj(), which returned -ERR_PRECONDITION_FAILED unless the
object's delete_at still matched. That check was lost in the zipper conversion
(72d1a36, pacific), so on reef/squid the object is deleted at the
earliest time ever set (this tracker). On main and tentacle,
RadosObject::handle_obj_expiry() checks is_expired() before deleting
(0e0222d), so the early deletion no longer happens there, but the stale
hints still accumulate and each one costs a head object read when processed.

This PR makes the ext key (object name) unique in cls_timeindex: an ext index
2_<key_ext> -> time index is maintained, and adding an entry for an existing
key_ext removes the old one. Trim removes the ext index only if it still points
to the trimmed entry, so entries left over from before the upgrade (no ext
index) don't break tracking of the newer ones; such legacy entries are cleaned
up when their time comes, as before.

For reef/squid a separate, rgw-only fix (restoring the expiration_time
precondition in garbage_single_object()) is proposed, as it does not
depend on the OSDs being upgraded.

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

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
  • jenkins retest this please
  • jenkins test classic perf
  • jenkins test crimson perf
  • jenkins test signed
  • jenkins test make check
  • jenkins test make check arm64
  • jenkins test submodules
  • jenkins test dashboard
  • jenkins test dashboard cephadm
  • jenkins test api
  • jenkins test docs
  • jenkins render docs
  • jenkins test ceph-volume all
  • jenkins test ceph-volume tox
  • jenkins test windows
  • jenkins test rook e2e

@dvanders
dvanders requested a review from a team October 7, 2024 18:54
@github-actions github-actions Bot added the stale label Dec 6, 2024
@github-actions

github-actions Bot commented Jan 5, 2025

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@soumyakoduri

Copy link
Copy Markdown
Contributor

@trociny changes look good to me. But when @shreyanshjain7174 was testing it, it dint remove duplicates seems like.

We are using Objectexpirer code to expire temporary restored objects from the cloud. So if a object entry is added twice, looks like its not overriding the first entry , even with this commit cherry-picked.

@shreyanshjain7174

Copy link
Copy Markdown

hey @trociny, I think you aiming to solve the problem of duplicate extended index keys (object names) in the cls_timeindex module which is correct I guess, but this is not solving the object_expirer duplicate entry, I think while retrieving from the map it might be taking first indexed value (just a hunch).

@trociny

trociny commented May 11, 2025

Copy link
Copy Markdown
Contributor Author

@soumyakoduri @shreyanshjain7174 Sorry for the delay with my response -- I was not available for these things. Hope, I will have time to work on it though. Could you please be more specific how you reproduced the issue so I could also try the scenario. I reproduced the issue using the steps I described in the ticket [1] and the fix worked for me. Note, as the change is for cls, it applies to osds, so you have to make sure you have updated and restarted the osds.

[1] https://tracker.ceph.com/issues/68380

@github-actions github-actions Bot added the stale label Jul 10, 2025
@github-actions github-actions Bot added the stale label Sep 8, 2025
@adamemerson adamemerson removed the stale label Sep 13, 2025
@ceph ceph deleted a comment from github-actions Bot Sep 13, 2025
@ceph ceph deleted a comment from github-actions Bot Sep 13, 2025
@ceph ceph deleted a comment from github-actions Bot Sep 13, 2025
@ceph ceph deleted a comment from github-actions Bot Sep 13, 2025
@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Nov 12, 2025
@trociny trociny removed the stale label Nov 15, 2025
@trociny

trociny commented Nov 15, 2025

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@github-actions

Copy link
Copy Markdown

This pull request has been automatically marked as stale because it has not had any activity for 60 days. It will be closed if no further activity occurs for another 30 days.
If you are a maintainer or core committer, please follow-up on this pull request to identify what steps should be taken by the author to move this proposed change forward.
If you are the author of this pull request, thank you for your proposed contribution. If you believe this change is still appropriate, please ensure that any feedback has been addressed and ask for a code review.

@github-actions github-actions Bot added the stale label Jan 14, 2026
@github-actions github-actions Bot added the stale label Jul 1, 2026
@github-actions

Copy link
Copy Markdown

This pull request has been automatically closed because there has been no activity for 90 days. Please feel free to reopen this pull request (or open a new one) if the proposed change is still appropriate. Thank you for your contribution!

@github-actions github-actions Bot closed this Jul 31, 2026
@trociny trociny removed the stale label Jul 31, 2026
@trociny trociny reopened this Jul 31, 2026
@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

@FredNass

Copy link
Copy Markdown
Contributor

@mdw-at-linuxbox @soumyakoduri @shreyanshjain7174 Could someone take a look at Mykola's update from August 24 so we can finally fix this bug?

@FredNass

Copy link
Copy Markdown
Contributor

@ivancich Can you help triage this ticket please? Hope you don't mind me asking. :-)

@soumyakoduri

Copy link
Copy Markdown
Contributor

@mdw-at-linuxbox @soumyakoduri @shreyanshjain7174 Could someone take a look at Mykola's update from August 24 so we can finally fix this bug?

@FredNass .. sorry I missed this note.. I will look at the latest changes.

string ext_index;
get_ext_index_key(key_ext, &ext_index);

ret = cls_cxx_map_remove_key(hctx, ext_index);

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.

trimming old entries (before upgrade) might end up removing newly added entries (after upgrade) with same key_ext.
Probably we should compare index values as well before removing the key here.

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.

Thanks. Fixed. remove_ext_index() now reads the ext index and removes it only if it points to the entry being trimmed. The LegacyEntries test covers it: an old-style entry (no ext index), a newer entry, trim the old one, and
check that the newer one is still replaced on the next add.

Comment thread src/test/cls_timeindex/CMakeLists.txt Resolved
trociny and others added 3 commits October 27, 2026 12:30
I.e. when adding an entry with key_ext that already exists the old
entry will be removed.

Although it changes expectations about how timeindex class works,
the only user of the class is rgw and it wants this behavior:
when adding an index (an object expiration time) we want the old index with
the same ext key (object name) to be removed as it is not valid anymore.

To find the old entry an ext index (key_ext -> time index) is
maintained. On trim the ext index is removed only if it points to
the entry being trimmed: entries added before the upgrade have no
ext index and are not replaced, and trimming them must not drop the
ext index of a newer entry.

Also, parse_index() now takes everything after the time prefix as
key_ext: sscanf("%255s") truncated long object names and stopped at
spaces, so trim computed a wrong ext index key and leaked it.

Fixes: https://tracker.ceph.com/issues/68380
Signed-off-by: Mykola Golub <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
cls_timeindex_add(op, list) and cls_timeindex_add(op, entry) were
defined with non-const arguments and cls_timeindex_add_prepare_entry()
was declared with a non-const bufferlist, so the declarations in the
header had no definitions and could not be used.

Signed-off-by: Mykola Golub <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Signed-off-by: Mykola Golub <[email protected]>
Co-Authored-By: Claude Opus 5.5 <[email protected]>
@trociny

trociny commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

@soumyakoduri Thank you for review. You comments have been addressed.

While there I also made parse_index() take everything after the time prefix as key_ext: the %255s sscanf truncated long object names and stopped at spaces, so trim computed the wrong ext key and leaked it.

Additionally, it turns out that the issue is not observed in recent versions. Originally a stale hint was harmless: the expirer passed hint.exp_time to RGWRados::delete_obj(), which returned -ERR_PRECONDITION_FAILED unless the
object's delete_at still matched. That check was lost in the zipper conversion (72d1a36, pacific), so on reef/squid the object is deleted at the earliest time ever set (this tracker). On main and tentacle, RadosObject::handle_obj_expiry() checks is_expired() before deleting (0e0222d), so the early deletion no longer happens there, but the stale
hints still accumulate and each one costs a head object read when processed. So this PR still makes sense though it is not so important any more.

The issue still exists in reef/squid. But for these it could be a separate, rgw-only fix (restoring the expiration_time
precondition in garbage_single_object()), as it does not depend on the OSDs being upgraded.

@trociny

trociny commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test make check

@trociny

trociny commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

jenkins test api

@anrao19

anrao19 commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao10-testing-2026-11-02-0708-main.

@anrao19

anrao19 commented Nov 13, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to wip-anrao10-testing-2026-11-02-0708-main.

pr testing completed and approved by @ivancich, more deatils in : https://tracker.ceph.com/issues/82524.
@trociny , if no further testing is needed then this can be merged

@anrao19
anrao19 merged commit c3e98d2 into ceph:main Nov 13, 2026
20 checks passed
@github-actions

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/43387122492

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