Skip to content

rgw: guard a delete's head removal on the ID tag it read - #72100

Closed
mmgaggle wants to merge 3 commits into
ceph:mainfrom
mmgaggle:wip-rgw-delete-idtag-guard
Closed

mmgaggle wants to merge 3 commits into
ceph:mainfrom
mmgaggle:wip-rgw-delete-idtag-guard

Conversation

@mmgaggle

@mmgaggle mmgaggle commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

55f5b762c67 ("fix conditional Delete and MultiDelete") replaced the delete's call to prepare_atomic_modification(removal_op=true), which added a cmpxattr on the ID tag, with check_preconditions, which adds nothing to the op. A delete that races an overwrite now removes the new head, then sends the manifest it read, the old one, to GC. The new object's tail, or a completion's parts, is never collected.

Guard the removal with append_atomic_test again. DeleteObject already answers the lost race's -ECANCELED with success; answer it the same way in multi-object delete, which reported it as an error before 55f5b762c67 as well.

The workunit case test_delete_racing_put in #72096 fails on main (the PutObject's tail remains after GC) and passes with this change on a vstart cluster.

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

With the removal guarded, a delete can lose the race to a write that replaced the head. DeleteObject answers that with success, which is right for an unconditional delete. A conditional one (If-Match, If-Match-Size, If-Match-Last-Modified-Time, If-Unmodified-Since) cannot claim its condition held, so the second commit answers its lost race with 409 ConditionalRequestConflict, in DeleteObject and in multi-object delete, and adds that error (https://tracker.ceph.com/issues/80906). The guard also closes a conditional delete deleting an object that fails its If-Match; the workunit case test_cond_delete_racing_put in #72096 fails on main and passes with this change.

Versioned buckets

In a bucket whose versioning is suspended, a DeleteObject of the null version logs the removal of the null instance, and whoever applies the olh log removes its head. If a PutObject wrote the key's head and linked a new null version in between, that removal took the new version's head: the version stayed current and lost its data. A new commit makes apply_olh_log cancel a pending removal when a later entry links the same instance as a version, with "null" and the empty instance treated as the same key.

Validated on vstart with the injection points of #72096: the workunit case test_suspended_delete_null_racing_put fails without the new commit and passes with it.

Not covered here:

  • when the guarded removal inside apply_olh_log loses a race, the error is treated as a race with another applier, and the rewritten head stays until the log is applied again;
  • a conditional DeleteObject with versionId=null checks its condition apart from the unlink, which needs a cls condition on unlink_instance, like the one rgw: link a conditional write's version only over the version it checked #72118 adds to link_olh.

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)

55f5b76 ("fix conditional Delete and MultiDelete") replaced the
delete's call to prepare_atomic_modification(removal_op=true), which
added a cmpxattr on the ID tag, with check_preconditions, which adds
nothing to the op. A delete that races an overwrite now removes the new
head, then sends the manifest it read, the old one, to GC. The new
object's tail, or a completion's parts, is never collected.

Guard the removal with append_atomic_test again. DeleteObject already
answers the -ECANCELED of a lost race with success; answer it the same
way in multi-object delete, which reported it as an error before
55f5b76 as well.

Fixes: https://tracker.ceph.com/issues/80898
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
@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
With the removal guarded on the ID tag it read, a delete can now lose
the race to a write that replaced the head, and gets -ECANCELED.
DeleteObject answers that with success, and so does multi-object delete
since the previous commit. That is right for an unconditional delete,
which counts as ordered before the write. A conditional one (If-Match,
If-Match-Size, If-Match-Last-Modified-Time, If-Unmodified-Since) cannot
claim its condition held: ordered before the write, its condition was
checked against a head that is gone, and ordered after it, the
condition was never checked against the new head.

Answer a conditional delete's lost race with 409
ConditionalRequestConflict, as S3 does for a conditional request that
loses to a concurrent operation, and add that error.

Fixes: https://tracker.ceph.com/issues/80906
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
In a bucket whose versioning is suspended, a DeleteObject of the null
version unlinks it, which logs the removal of the null instance on the
olh, and removes its head when the log is applied. The null version's
head is the key's olh head object, which a PutObject of a new null
version writes too. When that PutObject wrote the head and linked its
version after the removal was logged, but before the log was applied,
whoever applied the log, the PutObject itself or the delete, still
removed the null instance's head. The new version stayed current and
lost its data. The ID-tag guard on the removal does not help, as the
removal reads the head afresh.

apply_olh_log already cancels an instance's removal when the instance is
linked again after an unlink of the olh. Cancel it whenever a later entry
links the same instance as a version, as a new null version does. The
unlink logs the null instance as "null", the write as the empty
instance: treat them as the same. A null delete marker linked afterwards
still leaves the removal in place.

Tested on vstart: a DeleteObject of the null version held after its
unlink, and a PutObject that writes and links meanwhile. Without this
change the PutObject's version is current but its head has no object;
with it the object reads back whole.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
@pritha-srivastava

Copy link
Copy Markdown
Contributor

the handling for non-versioned buckets looks fine, although I am not sure about the version suspended part. Someone with experience in this part of code can help here @adamemerson

@cbodley

cbodley commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

A new commit makes apply_olh_log cancel a pending removal when a later entry links the same instance as a version, with "null" and the empty instance treated as the same key.

where is this commit?

edit: i now see commit "rgw: keep the head of a null version linked after its removal" for this

@soumyakoduri
soumyakoduri self-requested a review October 7, 2026 18:00

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

Since apply_olh_log() is called separately for each batch read from OLH log, this change seems to be addressing this race only when remove and subsequent relink are read in the same batch.
But in case the ops are split across different OLH log batches, it can still cause this data loss.

Comment thread src/rgw/rgw_op.cc
// delete counts as ordered before that write; a conditional one cannot
// claim its condition held, and answers a conflict for the client to
// retry
const bool conditional = if_match || size_match ||

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.

As mentioned in #71588 (review) , this error should be returned in ConditionalPut and ConditionalCopy cases too.

Is any of the other PRs handling this case for ConditionalPut? ConditionalCopy case probably can be handled as part of #71588 itself (if not done).

// again, whether or not it becomes current: keep its head. a null
// version written after a DeleteObject of the null version logged
// its removal shares the key's head object, and would lose it to
// that removal. a null delete marker linked after it does not

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: This applies to all delete_markers .. not just null right? Comment needs to be updated.

ldpp_dout(dpp, 20) << "apply_olh_log applying key=" << entry.key << " epoch=" << iter->first << " delete_marker=" << entry.delete_marker
<< " over current=" << key << " epoch=" << link_epoch << " delete_marker=" << delete_marker << dendl;

if (need_to_remove) {

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.

This block seems redundant now. Needs to be cleaned up.

[Also there seems to be bug here too.. As per this remove was getting cancelled for all entries including delete_marker (provided above if conditions are met). But as per new logic, delete_marker shouldn't be cancelling remove]

@RaminNietzsche

Copy link
Copy Markdown
Member

Hi — while scanning the open-PR backlog with the pr-triage read-only assistant, this pair stood out:

If #72945 is now the canonical branch, consider closing #72100 or marking it superseded to save review queue time. Happy to be wrong if both are intentionally kept open for different reasons.


pr-triage note — automated candidate for human review only, not a maintainer decision. Snapshot 2026-11-10 against open PR bases. pr-triage is a personal read-only assistant by @RaminNietzsche; not affiliated with or endorsed by the Ceph project. Please verify (rebase, git cherry, tracker) before acting.

@cbodley cbodley closed this Nov 17, 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.

7 participants