Skip to content

rgw: Fix crashes on realm reload - #68920

Merged
adamemerson merged 5 commits into
ceph:mainfrom
adamemerson:wip-76094
Jul 9, 2026
Merged

adamemerson merged 5 commits into
ceph:mainfrom
adamemerson:wip-76094

Conversation

@adamemerson

@adamemerson adamemerson commented May 14, 2026 •

Copy link
Copy Markdown
Contributor

Collection of fixes relevant to reload and shutdown.

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

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.

@github-actions

github-actions Bot commented Jun 9, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

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

Commits 1–7 look good. the io_context_pool init fix (commit 5) is a subtle catch, and I think the drain+restart on realm reload (commit 7) complements #66369.

Regarding commit 8 (strand-dispatched socket.close()): the pending #69713 addresses the same race differently: it replaces socket.close() with cancel() + shutdown(), similar to the approach added in the timeout handler #50131. This avoids releasing the fd from ConnectionList::close() entirely, so the race doesn't exist regardless of calling context.

Both approaches are functionally complementary (strand serialization + non-destructive shutdown), but either one alone ?may? be sufficient to fix such crashes. So, if #69713 lands in, commit 8 may become redundant.

@adamemerson / @cbodley - would you prefer one approach over the other, or should/can both go in?

@adamemerson

Copy link
Copy Markdown
Contributor Author

Commits 1–7 look good. the io_context_pool init fix (commit 5) is a subtle catch, and I think the drain+restart on realm reload (commit 7) complements #66369.

Regarding commit 8 (strand-dispatched socket.close()): the pending #69713 addresses the same race differently: it replaces socket.close() with cancel() + shutdown(), similar to the approach added in the timeout handler #50131. This avoids releasing the fd from ConnectionList::close() entirely, so the race doesn't exist regardless of calling context.

Both approaches are functionally complementary (strand serialization + non-destructive shutdown), but either one alone ?may? be sufficient to fix such crashes. So, if #69713 lands in, commit 8 may become redundant.

@adamemerson / @cbodley - would you prefer one approach over the other, or should/can both go in?

if there isn't a huge cost, I don't object to redundant fixes.

@BBoozmen

Copy link
Copy Markdown
Contributor

Commits 1–7 look good. the io_context_pool init fix (commit 5) is a subtle catch, and I think the drain+restart on realm reload (commit 7) complements #66369.
Regarding commit 8 (strand-dispatched socket.close()): the pending #69713 addresses the same race differently: it replaces socket.close() with cancel() + shutdown(), similar to the approach added in the timeout handler #50131. This avoids releasing the fd from ConnectionList::close() entirely, so the race doesn't exist regardless of calling context.
Both approaches are functionally complementary (strand serialization + non-destructive shutdown), but either one alone ?may? be sufficient to fix such crashes. So, if #69713 lands in, commit 8 may become redundant.
@adamemerson / @cbodley - would you prefer one approach over the other, or should/can both go in?

if there isn't a huge cost, I don't object to redundant fixes.

Agreed. Having both won't be really redundant I think...One serializes the operation on the connection's strand, and the other makes it a graceful shutdown by using cancel+shutdown instead of close, and relying on RAII to clear the connections list instead of explicit clear(). The only cost is some minor merge conflict resolution when the second to go in will need to rebase.

Comment thread src/rgw/rgw_realm_reloader.cc Resolved
Comment thread src/rgw/rgw_asio_frontend.cc Resolved
@github-actions

github-actions Bot commented Jul 1, 2026

Copy link
Copy Markdown

This pull request can no longer be automatically merged: a rebase is needed and changes have to be manually resolved

@adamemerson

Copy link
Copy Markdown
Contributor Author

Having got a crash in the testing, I'm going to put finalize() in for now. I'd be happy to work toward taking it out again, though. At the moment I just want to get these crashes fixed.

@adamemerson
adamemerson force-pushed the wip-76094 branch 2 times, most recently from 60de401 to ce3dfb3 Compare July 2, 2026 19:55
@adamemerson

Copy link
Copy Markdown
Contributor Author

jenkins test make check arm64

Comment thread src/neorados/cls/fifo/detail/fifo.h Resolved
adamemerson and others added 5 commits July 8, 2026 17:06
Without this we can end up in an infinite loop where we just fill the
log with -ECANCELED from `get_next()`. Duplicates a check in the
`blocked_operations` loop.

Fixes: https://tracker.ceph.com/issues/76094
Signed-off-by: Adam C. Emerson <[email protected]>
This is essentially a special case of an optional and it should act
like one.

I asked the original author to updated it but they didn't want to, so
I did it myself.

Fixes: https://tracker.ceph.com/issues/76094
Signed-off-by: Adam C. Emerson <[email protected]>
Previously if we received an rvalue function object we would call a
moved-from object on all but the first thread. In practice this didn't
cause an issue, but only because of the functions we were passing.

Fixes: https://tracker.ceph.com/issues/76094
Signed-off-by: Adam C. Emerson <[email protected]>
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]>

Update `unittest_rgw_asio_frontend` to run the `io_context` and
execute in a coroutine to match the environment in RGW.

Signed-off-by: Adam C. Emerson <[email protected]>
@cbodley

cbodley commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

@adamemerson

Copy link
Copy Markdown
Contributor Author

jenkins test windows

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