Repository navigation
rgw/beast: dispatch connection close on strand during pause - #68600
lumir-sliva wants to merge 1 commit into
Conversation
AsioFrontend::pause() (and stop()) call ConnectionList::close() from the realm reloader thread. That invokes socket.close() on every live connection from a thread that isn't the connection's asio strand, so the reactor deregisters each socket's descriptor_state racing against the coroutine that handles the connection. If a keep-alive connection is starting its next async_read_some() on its strand at the same time, epoll_reactor::start_op() dereferences the descriptor_state that close has already freed and radosgw segfaults in an io_context_pool thread. This matches the race pattern fixed for timeout_timer in 86ad0b8: any caller that touches socket state from outside the strand needs to be serialized with the coroutine. Store the coroutine's strand executor on Connection and dispatch the close onto that strand in ConnectionList::close(). The lambda captures an intrusive_ptr to Connection so the object lives until the close actually runs, since connections.clear() unlinks the list entry right after dispatch. Tracker: https://tracker.ceph.com/issues/76094 Signed-off-by: Lumir Sliva <[email protected]>
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
13 similar comments
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Thank you for your contribution. Since you, the author, are not a member of the Ceph GitHub Org yet, our CI will not automatically run. Any member of the Ceph Org may comment "ok - to - test" (without the dashes) to allow the Jenkins jobs to run. |
|
Sorry, I didn't notice this PR until now. I'm going to pull this commit onto pile of fixes I have, if that's all right. |
I guess I did see it, but I'd forgotten about it. Either way, I'd like to get all the fixes together so we can backport them together rather than having a bunch of different ones. |
No worries, happy to keep it as one commit in your series. Go for it. |
cbodley
left a comment
There was a problem hiding this comment.
thanks, looks correct to me but i'll defer to @adamemerson when/where this merges
|
This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved |
Summary
Fixes a race between
AsioFrontend::pause()and active keep-alive connections that crashes radosgw with a SIGSEGV in anio_context_poolthread during multisite period updates.Problem
When
radosgw-admin period update --commiton one zone pushes a new period to a peer, the peer's realm reloader callsAsioFrontend::pause(), which invokesConnectionList::close()to shut down live connections before rebuilding the driver.close()iterates the list and callssocket.close()on every connection from the reloader thread — not from the connection's asio strand.Each close makes the reactor deregister the socket's
descriptor_state. If a keep-alive connection is concurrently starting its nextasync_read_some()on its strand (which happens right after serving the inboundPOST /admin/realm/periodthat triggered the reload),epoll_reactor::start_op()dereferences adescriptor_statethat close has already freed — segfault inside the beastread_some_opdispatch chain.The stack trace on the teuthology run in the tracker matches: top frames are
epoll_reactor::start_op→reactive_socket_service_base::async_receive→beast::http::detail::read_some_op.Fix
Same pattern as 86ad0b8 (which fixed the
timeout_timerrunning off the strand): anything that touches socket state from outside the strand has to be serialized with the coroutine.Connectionat construction time (viayield.get_executor()inon_accept's spawn).ConnectionList::close()nowasio::dispatch()es thesocket.close()onto each connection's strand, so it runs in order with the coroutine's own socket ops.intrusive_ptr<Connection>so the object outlivesconnections.clear(), which unlinks the list entry immediately.Testing
radosgwwith the change on a vstart multisite (2 zones, 1 zonegroup) set up viasrc/test/rgw/test-rgw-multisite.sh.zonegroup modifyendpoint lists on the master, issuesperiod update --commiton the secondary, and floods the master's multisite gateway with concurrent keep-alive curls during each cycle.epoll_reactor::start_opwithin the first few iterations, with the same signature as the tracker stack.test_period_update_commitinsrc/test/rgw/rgw_multi/tests.py(added in 5e6a9c8) already exercises this exact path — concurrent S3 writes while running multiple period-update-commit cycles. That's the test that hit this crash on Casey's 2026-04-17 trial and will gate the fix in the rgw/multisite teuthology suite.Checklist
Tracker: https://tracker.ceph.com/issues/76094