Skip to content

[DNM]rgw/bilog: make bilog fifo push async - #72221

Open
smanjara wants to merge 4 commits into
ceph:mainfrom
smanjara:wip-fifo-bilog-async
Open

smanjara wants to merge 4 commits into
ceph:mainfrom
smanjara:wip-fifo-bilog-async

Conversation

@smanjara

Copy link
Copy Markdown
Contributor

Contribution Guidelines

  • To sign and title your commits, please refer to Submitting Patches to Ceph.

  • If you are submitting a fix for a stable branch (e.g. "quincy"), please refer to Submitting Patches to Ceph - Backports for the proper workflow.

  • When filling out the below checklist, you may click boxes directly in the GitHub web UI. When entering or editing the entire PR message in the GitHub web UI editor, you may also select a checklist item by adding an x between the brackets: [x]. Spaces and capitalization matter when checking off items this 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)
Show available Jenkins commands

You must only issue one Jenkins command per-comment. Jenkins does not understand
comments with more than one command.

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

very cool

Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
@smanjara
smanjara force-pushed the wip-fifo-bilog-async branch from cbcd522 to 582803a Compare October 2, 2026 18:56

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

one thing i'm not clear on is where the fifo-bilog write is happening. is it still outside the coroutine, so synchronous wrt do_write_meta()? can the with_bilog() call move into the coroutine too?

Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
@smanjara

smanjara commented Oct 6, 2026

Copy link
Copy Markdown
Contributor Author

one thing i'm not clear on is where the fifo-bilog write is happening. is it still outside the coroutine, so synchronous wrt do_write_meta()? can the with_bilog() call move into the coroutine too?

oh the bilog write is happening within the coroutine. index_completion_manager->spawn() -> cls_obj_complete_add/del/cancel() -> cls_obj_complete_op() -> with_bilog -> flush() → do_flush() → fifo_->push. with_bilog/flush actually runs on the spawned stack with the oy and not on the _do_write_meta's optional_yield.

@anrao19

anrao19 commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-10-09-10:05.

@anrao19

anrao19 commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

This PR has been added to main integration testing by anuchaithra started 2026-10-09-10:05.

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

@smanjara

Copy link
Copy Markdown
Contributor Author

This PR has been added to main integration testing by anuchaithra started 2026-10-09-10:05.

two tests are failing here: test_versioned_object_incremental_sync() and test_concurrent_versioned_object_incremental_sync()

@smanjara
smanjara force-pushed the wip-fifo-bilog-async branch from b490e1a to dfb81db Compare October 26, 2026 20:18
@smanjara

Copy link
Copy Markdown
Contributor Author

This PR has been added to main integration testing by anuchaithra started 2026-10-09-10:05.

two tests are failing here: test_versioned_object_incremental_sync() and test_concurrent_versioned_object_incremental_sync()

the multisite test timed out because bucket shard 3's bilog moved past the marker incremental sync had stored, and nothing wrote another datalog entry to make c2 read that shard again.
complete() returns when it spawns. _do_write_meta then calls set_olh, and link_olh copies the instance entry prepare left behind (exists == false, pending tag still set) onto the object instance list entry. the spawned child later clears that tag only on the instance entry. but listing reads the list entry, so full sync's list_bucket still sees a pending entry, check_disk_state pushes one more fifo ADD, and that path does not call add_datalog_entry.

as a fix, added a helper function in rgw_bucket_complete_op's CLS_RGW_OP_ADD, where the pending tag is cleared and exists is set on the instance key. If link_olh has already copied that instance onto the list entry, the complete op copies the finished fields onto the list entry.

@smanjara

smanjara commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor Author

as a fix, added a helper function in rgw_bucket_complete_op's CLS_RGW_OP_ADD, where the pending tag is cleared and exists is set on the instance key. If link_olh has already copied that instance onto the list entry, the complete op copies the finished fields onto the list entry.

@cbodley, I still feel like we need this fix. link_olh copies the instance entry onto the list key while prepare's tag is still in pending_map and exists is still false. the spawned complete_op then erases that tag and sets exists to true only on the instance key. without the fix, the list key stays as link_olh wrote it. every later listing of that name enters check_disk_state on both !dirent.exists and !dirent.pending_map.empty().
on a fifo bilog that flush is an extra add. rgw_dir_suggest_changes leaves the list key unchanged because that tag is within the rgw_pending_bucket_index_op_expiration window. a datalog write here doesn't solve the cause, it would just add another wasteful datalog entry for something that doesn't repair the index.
but for a real bucket index repair case, we still need to add the datalog entry, which is missing for both fifo and inindex.

to solve the ordering issue, you suggested moving set_olh into the coroutine.. the coroutine could suspend on rctx.y with some kind of yield waiter until the child finishes. the thread itself could be made non-blocking, but the PUT request will still have to wait for both the results, right?

@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

@smanjara

Copy link
Copy Markdown
Contributor Author

Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
Comment thread src/cls/rgw/cls_rgw.cc
__func__, escape_str(idx).c_str(), rc);
return rc;
}
rc = update_versioned_list_key(hctx, entry, idx, header);

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 discussed, fixing up the list index entry should happen in link_olh instead

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't clear during the discussion, sorry. the problem is not that link_olh skips updating the list key. it writes both keys from the same instance_entry (obj.write → write_obj_entries → get_list_index_key → write_entry). but that list write is a copy of the instance as link_olh sees it. complete_op is what actually completes the instance. link_olh only copies whatever is already there. if complete_op has not finished, that copy is still prepare’s stub.

the race occurs only because index completion is asynchronous w.r.t link_olh. I am not sure what other parts of olh could be racing first, worse if complete_op fails and link_olh never saw it. it might make more sense if we moved set_olh into the coroutine.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the race occurs only because index completion is asynchronous w.r.t link_olh. I am not sure what other parts of olh could be racing first, worse if complete_op fails and link_olh never saw it. it might make more sense if we moved set_olh into the coroutine.

hmm moving set_olh into the coroutine would give up read-after-write guarantee stated in https://github.com/ceph/ceph/blob/main/doc/dev/radosgw/bucket_index.rst#L55-L63 if PUT returns success before the current version is set.

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.

if complete_op has not finished, that copy is still prepare’s stub

right, the suggestion was for link_olh to modify these copied entries before writing them so they are complete (exists=true pending_map=empty)

the link_olh operation itself writes a CLS_RGW_OLH_OP_LINK_OLH entry to the bilog. is there any need for this list entry to remain "pending", so that dir suggest can resend that bilog entry if necessary?

hmm moving set_olh into the coroutine would give up read-after-write guarantee

agreed

@smanjara smanjara Nov 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the link_olh operation itself writes a CLS_RGW_OLH_OP_LINK_OLH entry to the bilog. is there any need for this list entry to remain "pending", so that dir suggest can resend that bilog entry if necessary?

listing reads this key and if 'pending' is cleared with exists=true, we will lose the ability to repair the index during dir_suggest. check_disk_state runs under this condition.

Comment thread src/rgw/driver/rados/rgw_rados.cc Resolved
complete/del/cancel spawn a coroutine on the io_context so the
request does not wait on cls complete_op. the child yields through
guard_reshard and operate, then writes the datalog entry after the
bilog.
remove the aio complete_op retry thread. the spawned child covers
ERR_BUSY_RESHARDING

on shutdown and realm reload, RadosStore::shutdown() stops the
background workers that can submit completions (sync, lc, obj
expirer, restore, reshard, bucket logging), then waits for spawned
children without cancelling them, before the datalog is shut down.

Signed-off-by: Shilpa Jagannath <[email protected]>
async complete() returns when it spawns, and set_olh then calls
link_olh. link_olh copies the instance entry prepare left behind onto
the list entry. complete_op clears the pending tag only on the instance
entry, so a later full-sync list still sees the pending list entry.
check_disk_state pushes a fifo bilog record and does not write a
datalog entry, so incremental sync never catches up.

after complete_op's ADD, if link_olh has already set versioned_epoch,
rewrite the list entry from the finished instance entry in the same
cls operation.
the versioned_epoch conditional covers a null version as well.

Signed-off-by: Shilpa Jagannath <[email protected]>
@smanjara
smanjara force-pushed the wip-fifo-bilog-async branch from 3e001f0 to d389862 Compare November 18, 2026 06:34
@smanjara

smanjara commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor Author

updated c307982 to rewrite IndexCompletionManager to drain and wait for coroutines to finish. Shutdown order is:

  • stop accepting new frontend requests
  • stop background workers that can still submit index completions.
  • drain RGWIndexCompletionManager (let existing children finish without cancellation, wait for them)
  • datalog blocking_shutdown()
  • context_pool->finish()
  • RGWRados finalize()
  • svc.shutdown()

a few caveats to note:

  • waiting for the outstanding coroutines means the shutdown may hang if the child is stuck in operate()/osds are slow to respond. timed wait and then cancel could be a useful improvement.
  • as @BBoozmen pointed out, datalog errors in the child are logged but cannot fail the S3 request (complete() already returned). returning them would mean joining the child.

cc @adamemerson

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

Thank you @smanjara , looks good! Just two more questions wrt the reshard retry/datalog generation and the logged reply.

As for the missing datalog entry after a listing repair: I ran the test from #73830 on top of this PR (no autotrim heal), and they pass for both InIndex and FIFO bilogs, so that part is indeed solved here 👍

We can talk more about this in #73830; I see these two PRs complementing each other:

  • this PR fixes the source on main, and
  • #73830 is a safety net that heals shards that are already stuck (and other causes of a lost datalog entry like during shutdown)

More importantly, AFAICT this PR isn't meant for tentacle/umbrella, since it builds on the FIFO bilog work on main while we can backport #73830 to alleviate this problem we're facing today.

std::ignore = store->cls_obj_complete_add(
&dpp, bucket_info, bs, obj, tag, pool, epoch, ent, category,
&remove_objs, bilog_flags, y, &zones_trace, log_op);
if (add_log) {

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.

Aren't we changing the behaviour here in the presence of a reshard?

Now, the lambda function captures bucket_info and updates it in init above.

cls_obj_complete_add could hit resharding -> guard_reshard(dpp, &bs, obj, info, ...) which re-inits bucket_info (which is correct).

Then, below in the if-body we are still using the earlier-init'ed (now stale) bucket_info, right?

int cls_obj_complete_op(const DoutPrefixProvider* dpp, const RGWBucketInfo& bucket_info, ....
RGWBucketInfo info = bucket_info;

Perhaps, you can drop "const" and then not copy it in guard_reshard?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks! you're right. also, reshard is where we upgrade to fifo. so if there was a completion underway during reshard, we could miss a bilog entry. that required some extra handling in 1087b85

op.assert_exists();
cls_rgw_guard_bucket_resharding(op, -ERR_BUSY_RESHARDING);
cls_rgw_suggest_changes(op, updates, &reply);
int r = rgw_rados_operate(&dpp, ioctx, oid, std::move(op), y);

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.

should we not set the OPERATION_RETURNVEC flag to really get the payload (i.e., reply) since this is write op?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

right, I originally thought we could skip datalog when dir_suggest didn't apply anything to the in-index bilog. but cls_rgw_suggest_changes has no outbl, so the flag wasn't written to. a spurious datalog entry should be harmless. I have dropped the flag now.

check_disk_state writes a fifo bilog record and never a datalog entry, so
incremental sync never saw the repair. write the datalog entry after a
successful fifo flush. for InIndex, the bilog entry is written by
dir_suggest, so spawn the dir suggest, wait for it to complete and
then add the datalog entry.

Signed-off-by: Shilpa Jagannath <[email protected]>
cls_obj_complete_op() picks the bilog backend once, before guard_reshard().
if a reshard upgrades an InIndex bucket to fifo while the completion is
blocked, the -ERR_BUSY_RESHARDING retries in the new index layout but
the InIndex backend it started with writes nothing to the new fifo log,
and the datalog entry is built from the stale bucket_info.

on a retry that sees this upgrade, write the bilog entry to the new fifo
generation once and use the updated bucket_info for datalog entry.

Signed-off-by: Shilpa Jagannath <[email protected]>
@smanjara
smanjara force-pushed the wip-fifo-bilog-async branch from d389862 to 1087b85 Compare December 1, 2026 01:03
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.

4 participants