Skip to content

rgw: a copy onto itself writes only over the head it copied - #72101

Open
mmgaggle wants to merge 2 commits into
ceph:mainfrom
mmgaggle:wip-rgw-copy-self-guard
Open

mmgaggle wants to merge 2 commits into
ceph:mainfrom
mmgaggle:wip-rgw-copy-self-guard

Conversation

@mmgaggle

@mmgaggle mmgaggle commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

A metadata-only copy of an object onto itself (copy_itself) reads the source's manifest, then writes it back with keep_tail. The destination has its own RGWObjectCtx, so write_meta reads the head afresh and guards on whatever ID tag it finds then. An overwrite between the two steps replaces the head and sends the old tail to GC; the copy then writes that tail back into the head. GC deletes the tail the head names, and the overwrite's own tail leaks.

Add MetaParams::id_tag_guard, a cmpxattr on the ID tag the caller read, placed before prepare_atomic_modification() sets the new one, and skip the exclusive create for a guarded write, which would recreate a head deleted meanwhile. copy_obj guards a copy onto itself on the source's ID tag. A copy that fails the guard is answered as success, like any lost race.

The s3-test test_object_copy_to_itself_racing_put (https://github.com/mmgaggle/s3-tests/tree/wip-rgw-overwrite-races), with the injection points in #72096, fails on main (GET stops after the head's 4 MiB, ENOENT on the tail) and passes with this change on a vstart cluster.

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

Versioned buckets and attribute updates

Attribute updates: PutObjectTagging, PutObjectAcl and the other set_attrs callers give the head a new ID tag and keep the object. A copy onto itself that raced such an update failed its guard and was answered success without writing, so its new metadata was lost. A new commit makes a copy onto itself that loses its guard read the head again and retry, up to twice, and answer 500 InternalError if it still loses. Reported in review by @mheler.

Versioned buckets: with versioning enabled, a copy onto the same key writes a new instance, so it is never a copy onto itself. With versioning suspended and another version current, the source resolves to that version and the copy takes references on its tail. With the null version current, the copy is a copy onto itself of the olh's head, and the guard applies.

Validated on vstart with the injection points of #72096: test_copy_to_itself_racing_tagging and test_copy_to_itself_racing_acl fail without the new commit and pass with it; test_suspended_copy_to_itself and test_suspended_copy_null_to_itself pass. The P model (#72110) checks the tagging race on main, with this guard, and with the retry: only the retry holds.

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)

@github-actions github-actions Bot added the rgw label Sep 26, 2026
@mmgaggle
mmgaggle marked this pull request as ready for review September 26, 2026 08:00
@mmgaggle
mmgaggle requested a review from a team as a code owner September 26, 2026 08:00
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
A metadata-only copy of an object onto itself (copy_itself) reads the
source's manifest, then writes it back with keep_tail. The destination
has its own RGWObjectCtx, so write_meta reads the head afresh and guards
on whatever ID tag it finds then. An overwrite between the two steps
replaces the head and sends the old tail to GC; the copy then writes
that tail back into the head. GC deletes the tail the head names, and
the overwrite's own tail leaks. A copy racing a delete does the same
through write_meta's exclusive create.

Add MetaParams::id_tag_guard, a cmpxattr on the ID tag the caller read,
placed before prepare_atomic_modification() sets the new one, and skip
the exclusive create for a guarded write. copy_obj guards a copy onto
itself on the source's ID tag. A copy that fails the guard is answered
as success, like any lost race.

Fixes: https://tracker.ceph.com/issues/80900
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
A copy of an object onto itself writes only over the head it read. When
the head changed since, it was answered success without writing
anything, like a lost race. That holds for a racing write, which
replaced the object, but not for an attribute update: PutObjectTagging,
PutObjectAcl and the other set_attrs callers give the head a new ID tag
while they keep the object. The copy's new metadata was then lost,
though the copy was answered success. Without the guard, as on main, the
copy wrote back the tag set it read over the update's, or lost its own
race the same way.

Run the copy again from the head as it is now, up to twice, with the
request's attributes, and answer 500 InternalError if it still loses.

Reported in review by mheler. Tested on vstart: a copy onto itself with
new metadata, held after it reads the head, and a PutObjectTagging or
PutObjectAcl meanwhile. Without this change the copy is answered success
and the object has no new metadata; with it the object carries both the
copy's metadata and the update's tag set.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
@adamemerson
adamemerson requested a review from mheler October 2, 2026 22:04
@mmgaggle

mmgaggle commented Oct 5, 2026

Copy link
Copy Markdown
Member Author

@cbodley ok to merge?

@cbodley

cbodley commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

@cbodley ok to merge?

no, it needs regression testing in teuthology - hence the needs-qa label

@cbodley

cbodley commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

p.s. if you wrote test cases for this, they need to be part of this pr so they're included in qa validation

@anrao19

anrao19 commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-10-06-07:40.

@cbodley

cbodley commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

@adamemerson @anrao19 i assume this needs tests from #72096 for validation, but that includes tests for lots of other prs too. how should we coordinate this testing?

@anrao19

anrao19 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

@adamemerson @anrao19 i assume this needs tests from #72096 for validation, but that includes tests for lots of other prs too. how should we coordinate this testing?

pr testing completed and approved by @ivancich, more details in https://tracker.ceph.com/issues/81454.
@mmgaggle , if further is not needed then this can be merged

@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

@adamemerson adamemerson removed their assignment Nov 18, 2026
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.

5 participants