Skip to content

rgw: answer a conditional request that loses the race with a conflict - #72109

Open
mmgaggle wants to merge 5 commits into
ceph:mainfrom
mmgaggle:wip-rgw-cond-lost-race
Open

mmgaggle wants to merge 5 commits into
ceph:mainfrom
mmgaggle:wip-rgw-cond-lost-race

Conversation

@mmgaggle

@mmgaggle mmgaggle commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Depends on #72100; the first two commits are #72100's.

A conditional request that loses the race for the head is answered as done_cancel maps the error, and the mapping is wrong both ways (https://tracker.ceph.com/issues/80906):

  • With If-Match: *, -ECANCELED becomes success, though the write never happened. Racing a PutObject with If-Match on the old ETag, both are answered 200 while the head holds the other write, and no order of the two explains both answers. If-None-Match: * answers -ENOENT the same way.
  • With If-Match on an ETag, -ECANCELED has no S3 error and is answered 500 UnknownError.

Answer each of these with 409 ConditionalRequestConflict, as S3 does for a conditional request that loses to a concurrent operation; the error is added in #72100, which answers a conditional delete's lost race the same way. The answers that already say what happened, 412 and 404, stay.

A completion with If-None-Match: * that loses the race to create the key is refused, and its upload stays, but the cancel of its index op has already removed its parts' index entries (https://tracker.ceph.com/issues/80907). Decide the answer first, and cancel without remove_objs when the write is answered with an error.

The workunit cases test_conditional_puts_race, test_if_match_losing_race and test_refused_complete_keeps_parts in #72096 fail on main and pass with this change on a vstart cluster. The fixes were checked in a formal model of these paths before they were written.

Versioned buckets

This branch now contains the new commit on #72100, which keeps a null version's head when it is linked after a DeleteObject of the null version logged its removal. The answer this PR gives a conditional request that loses a race, 409 ConditionalRequestConflict, is the one S3's API model gives a conflicting operation during a conditional write. #72118 now answers a conditional write refused at its olh link the same 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)

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]>
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]>
done_cancel answers a write that lost the race for the head as its
condition dictates. For If-Match: * it answers -ECANCELED with success,
though the write never happened: racing a PutObject with If-Match on
the old ETag, both are answered 200 while the head holds the other
write, and no order of the two explains both answers. For If-Match with
an ETag, -ECANCELED has no S3 error and is answered 500 UnknownError.
If-None-Match: * answers -ENOENT with success in the same way.

Answer each of these with 409 ConditionalRequestConflict, as S3 does
for a conditional request that loses to a concurrent operation. The
answers that already say what happened, 412 and 404, stay.

Fixes: https://tracker.ceph.com/issues/80906
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
When a write loses the race for the head, done_cancel cancels its index
op, and the cancel applies remove_objs, then decides how to answer. A
completion with If-None-Match: * that loses the race to create the key
is refused with 412, and its upload stays: it can be completed again or
aborted. But the cancel has already removed its parts' index entries,
and the bucket stats undercount the parts until the upload is gone.

Decide the answer first, and cancel without remove_objs when the write
is answered with an error: its request stays, and so do the entries it
would have replaced. A lost race answered as success still removes
them.

Fixes: https://tracker.ceph.com/issues/80907
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
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.

3 participants