Skip to content

osdc: deliver neorados completions to associated executor - #69253

Merged
cbodley merged 2 commits into
ceph:mainfrom
cbodley:wip-76725
Jun 9, 2026
Merged

cbodley merged 2 commits into
ceph:mainfrom
cbodley:wip-76725

Conversation

@cbodley

@cbodley cbodley commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

while Objecter delivers librados completions directly by calling Context::complete(), neorados completions are passed in as boost::asio::any_completion_handler and delivered to an asio executor via boost::asio::defer() on completion

asio handlers may have an "associated executor" so callers can customize where these completions are delivered. for example, multithreaded applications often use strand executors to synchronize completion handlers and prevent data races between concurrent operations

however, applications like radosgw that depend on strands for thread-safety did not get it due to the fact that Objecter's Op::complete() delivered all neorados completions to the default io_context executor

use boost::asio::get_associated_executor() to respect the handler's executor affinity, if any

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

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 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor Author

fix credited to @BBoozmen from #69193 (comment)

@cbodley
cbodley requested a review from a team June 2, 2026 20:45
@smanjara

smanjara commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

@cbodley make check is failing

/ceph/src/osdc/Objecter.h:2076:8: error: no matching function for call to 'defer'
2076 | boost::asio::defer(ex,
| ^~~~~~~~~~~~~~~~~~

while Objecter delivers librados completions directly by calling
Context::complete(), neorados completions are passed in as
boost::asio::any_completion_handler and delivered to an asio executor
via boost::asio::defer() on completion

asio handlers may have an "associated executor" so callers can customize
where these completions are delivered. for example, multithreaded
applications often use strand executors to synchronize completion
handlers and prevent data races between concurrent operations

however, applications like radosgw that depend on strands for
thread-safety did not get it due to the fact that Objecter's
Op::complete() delivered all neorados completions to the default
io_context executor

use boost::asio::get_associated_executor() to respect the handler's
executor affinity, if any. but because the Op's handler is the
type-erased any_completion_handler, its associated executor is also
type-erased as any_completion_executor. that any_completion_executor
doesn't support the blocking::never_t property required by defer/post,
so defer() was changed to dispatch() which may call the handler directly
if Objecter is already running on the requested executor. i assume this
is safe, given that librados' Context-based completions already do this

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

Co-Authored-by: Oguzhan Ozmen <[email protected]>
Signed-off-by: Casey Bodley <[email protected]>
@cbodley

cbodley commented Jun 3, 2026

Copy link
Copy Markdown
Contributor Author

oops, thanks! template argument deduction was failing there on:

can_require<Executor, execution::detail::blocking::never_t<0> > [with Executor = boost::asio::any_completion_executor]

i changed defer() to dispatch() with this update to the commit message:

[...] because the Op's handler is the type-erased any_completion_handler, its associated executor is also type-erased as any_completion_executor. that any_completion_executor doesn't support the blocking::never_t property required by defer/post, so defer() was changed to dispatch() which may call the handler directly if Objecter is already running on the requested executor. i assume this is safe, given that librados' Context-based completions already do this

@smanjara
smanjara self-requested a review June 3, 2026 15:00
@mkogan1

mkogan1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

hi, updating that in ASAN testing an ASAN issues still repro after this fix, but much more sporadically that before it, @BBoozmen @cbodley @smanjara @adamemerson PTAL, the repro env is up and I can run ASAN repro validation on any ideas for code changes or conf change suggestions like playing with rgw_thread_pool_size, rgw_max_concurrent_requests, rgw_multi_obj_del_max_aio, other aio tunables ...

asan.log.518406.log
asan.log.2003220.log

repurpose ceph_test_neorados_completions to verify that completions are
delivered to the handler's associated executor

Signed-off-by: Casey Bodley <[email protected]>
@cbodley
cbodley requested a review from a team as a code owner June 4, 2026 18:40
@cbodley

cbodley commented Jun 4, 2026

Copy link
Copy Markdown
Contributor Author

i was able to write a test case to validate the change. run against an unpatched neorados, the test hangs on completion_context.run() waiting a completion that doesn't come. with the fix applied, the test completes successfully

@BBoozmen

BBoozmen commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

hi, updating that in ASAN testing an ASAN issues still repro after this fix, but much more sporadically that before it, @BBoozmen @cbodley @smanjara @adamemerson PTAL, the repro env is up and I can run ASAN repro validation on any ideas for code changes or conf change suggestions like playing with rgw_thread_pool_size, rgw_max_concurrent_requests, rgw_multi_obj_del_max_aio, other aio tunables ...

asan.log.518406.log asan.log.2003220.log

Just making sure did you cherry-pick aabb5c7 to your test repo? because looking at new asan log:

#16 0x55555740d317 in RGWDeleteMultiObj_ObjStore_S3::send_partial_response(rgw_obj_key const&, bool, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int) /mnt/osd--host/src-git/ceph--
up--main/src/rgw/rgw_rest_s3.cc:4978

send_partial_response is at line 4978 which makes sense given your mutex branch https://github.com/mkogan1/ceph/blob/2d37be734948cf1b8675a710769023d0c656dde9/src/rgw/rgw_rest_s3.cc#L4948 but looking at this PR the same function is at line 5016 https://github.com/cbodley/ceph/blob/c4d9a406c8e9ed514067a37574dec88a794acd7c/src/rgw/rgw_rest_s3.cc#L5016 - trying to undertsand are we running both fix (mutex + this one) or just this one.

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.

5 participants