Repository navigation
Conversation
_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]>
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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.
|
@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 |
Three fixes to how
write_meta's callers handle a write that did not take effect._do_write_metatreats an error fromindex_op->completelike a lost race, after the head is written, and callers then undo what the new head names: PutObject deletes the tail, a copy drops its references, a completion skips its meta delete. On main this is reachable sincea67a233ccbd, where a FIFO-bilog bucket flushes its bilog batch before the completion op. Keep the write, leave the pending op for a listing to repair, and still remove the entries the write replaces, with a cancel without a tag. After this,meta.canceledmeans the head was not written.copy_objrolls back its references on the source's tail only whenwrite_metareturns an error; a lost race returns 0 withmeta.canceledset, and the source's tail outlives the source.RadosMultipartUpload::completeignoresmeta.canceled; its parts become unreferenced and are never collected.The last two rely on the first: without it,
meta.canceledcan be set after the head was written, and cleaning up would free data the head names.The workunit cases
test_losing_copyandtest_losing_completein #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_olhfails after it, as this PR already does for a failed index completion. Before,set_olhreturned 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_keyoption 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