Skip to content

rgw: keep a write whose index completion fails, and clean up after lost head races - #72098

Open
mmgaggle wants to merge 4 commits into
ceph:mainfrom
mmgaggle:wip-rgw-write-meta-canceled
Open

mmgaggle wants to merge 4 commits into
ceph:mainfrom
mmgaggle:wip-rgw-write-meta-canceled

Conversation

@mmgaggle

@mmgaggle mmgaggle commented Sep 26, 2026 •

Copy link
Copy Markdown
Member

Three fixes to how write_meta's callers handle a write that did not take effect.

The last two rely on the first: without it, meta.canceled can be set after the head was written, and cleaning up would free data the head names.

The workunit cases test_losing_copy and test_losing_complete in #72096 fail on main and pass with this change on a vstart cluster. The index-completion failure has no cluster reproducer, since it needs a bilog flush to fail; it was checked with a formal model of these paths (https://github.com/mmgaggle/ceph/tree/cdbbbb09245535782e91503ad45b0cc7a423e10d/src/test/formal/p/rgw_overwrite).

Versioned buckets

A write in a versioned bucket, or of a null version over a key with an olh, links its version to the olh after its head write and index completion. A new commit keeps such a write when the bilog flush or the datalog entry fails after the index has linked the version, or when update_olh fails after it, as this PR already does for a failed index completion. Before, set_olh returned the error and the caller undid what the now current version names.

The bilog or datalog entry that failed is not written, so multisite sync can miss the change, as for a failed index completion.

Validated on vstart with the new rgw_debug_inject_link_olh_log_err_key option of #72096: a PutObject with versioning enabled and suspended, and a CompleteMultipartUpload followed by an abort. Each leaves a current version that cannot be read without the new commit, and reads back whole with it.

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)

_do_write_meta treats an error from index_op->complete like a lost
race: it cancels the index op and returns through done_cancel. By then
the head is written. Depending on the error the caller sees either a
canceled write or a failure, and undoes what the new head names:
PutObject's writer deletes the tail, a copy drops its references on the
source's tail, and a multipart completion returns before deleting its
meta object. The object then reads a missing tail, or loses it once the
source is gone. If the cancel succeeds, the index also keeps listing the
old object.

The completion can fail after the head write when a FIFO-bilog bucket
flushes its bilog batch (with_bilog, a67a233), or when the datalog
entry cannot be added, whose error replaces the completion's.

Keep the write. Log the error and leave the pending op, as done_cancel
already does for -ETIMEDOUT, so that a bucket listing repairs the entry
from the head with check_disk_state. The entries the write replaces,
such as a multipart completion's parts, are still removed, through a
cancel without a tag (UpdateIndex::complete_remove_objs): the listing
repairs only the head it finds, and a later write may have replaced
this one by then. meta.canceled now means the head was not written.

Fixes: https://tracker.ceph.com/issues/80902
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
copy_obj takes a reference on each of the source's tail objects before
it writes the destination's head, and rolls them back only when
write_meta returns an error. A lost race is answered as success with
meta.canceled set, so the references stay. Once the source is deleted
or overwritten, GC drops the source's own reference but not the copy's,
and the tail outlives every head that could name it.

Roll the references back when the write was canceled, too.

Fixes: https://tracker.ceph.com/issues/80899
Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
RadosMultipartUpload::complete ignores meta.canceled. When another
write of the key wins the head race, the completion is answered as
success, its index cancel removes the parts' index entries, and the
caller deletes the meta object. Nothing then names the parts, and
nothing collects them.

Send the canceled completion's parts to GC under the upload id, as an
abort does. meta.canceled means the head was not written.

Fixes: https://tracker.ceph.com/issues/80897
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
A write in a versioned bucket, or of a null version over a key with an
olh, links its version to the olh after its head write and index
completion. set_olh returned an error when the bilog flush or the
datalog entry failed after the bucket index had linked the version, or
when update_olh failed after it. The caller then undid what the now
current version names, as for a failed index completion: PutObject's
writer deleted its tail, a copy dropped its references, and a multipart
completion returned before deleting its meta object, so an abort sent
the parts to GC. The version stayed current, and a GET of it failed.

Once the index links the version, the link stands: log these errors and
answer success, as this series already does for a failed index
completion. A failed update_olh leaves the olh's pending log entry,
which a read that follows the olh applies. A link that the index refuses
is still an error.

The bilog or datalog entry that failed is not written, so multisite
sync can miss the change, as for a failed index completion.

Tested on vstart with rgw_debug_inject_link_olh_log_err_key: a PutObject
with versioning enabled and suspended, and a CompleteMultipartUpload
followed by an abort. Without this change each leaves a current version
that cannot be read after GC. With it each is answered success and reads
back whole.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: Kyle Bader <[email protected]>
// the entries the write replaces, such as a completion's parts, are
// its own to remove. a listing repairs only the head it finds, which a
// later write may have replaced by then
int ret = index_op->complete_remove_objs(rctx.dpp, meta.remove_objs, rctx.y, log_op);

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.

thanks @mmgaggle. this commit has two related fixes: one for a data loss bug, and another to clean up orphaned index entries on an error path

for the data loss bug, i agree that we shouldn't goto done_cancel and try to cancel the op. bucket listing will eventually trigger the dir-suggest recovery 👍

regarding the other fix for orphaned index entries, i think this complete_remove_objs() part needs more thought. this is an error path for index_op->complete(), but that index completion is asynchronous so we shouldn't expect to see errors here. from your commit message:

The completion can fail after the head write when a FIFO-bilog bucket flushes its bilog batch (with_bilog, mmgaggle@67a233c), or when the datalog entry cannot be added, whose error replaces the completion's.

the fifo-bilog stuff is brand new (cc @smanjara), and i pointed out in #67774 (comment) that the bilog write shouldn't be synchronous wrt write_meta(). the same goes for the datalog write, but even so - an error from add_datalog_entry() doesn't mean that we won't or didn't succeed to call cls_rgw.cc: rgw_bucket_complete_op()

in my view, the larger problem is that our dir-suggest model for crash recovery doesn't track remove_objs for this cleanup. i think we should track this as a separate issue from the data loss bug, and avoid adding a complete_remove_objs() for this error path we don't expect to run

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 just opened a PR for the bilog async part #72221

if (r < 0) {
// the index links the version, so the link stands. failing here would
// have the caller free what the now current version names, as a
// failed index completion after a head write would

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 don't love this change. We've been going to quite a lot of effort to get rid of "Write succeeds, doesn't replicate for some reason."

// the index links the version: the link stands
ldpp_dout(dpp, 0) << "ERROR: " << __func__
<< ": failed to add datalog entry, ret=" << r << dendl;
r = 0;

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.

The contract is that if the datalog write fails thus causing the replication to mysteriously not happen, we error. This is undoing the entire idea that if the write succeeds it gets replicated.

@kchheda3

Copy link
Copy Markdown
Contributor

@cbodley @adamemerson the data-loss fix and Adam's concern look compatible, and I had a slightly different idea: let's keep the write — no cancel, and leave the pending entry for dir-suggest as Casey suggested — but still return a retryable error, like we already do for -ETIMEDOUT (23fcab7, 0c578a1).

The processors keep the tails once the head is written, so nothing is lost. The client's retry then writes its own bilog/datalog entries, so the change still gets replicated.

I put this up as a draft with an injection test: #74065
Tracker: https://tracker.ceph.com/issues/83295

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.

6 participants