Skip to content

mon/MonClient: check stopping for auth request handling - #68245

Merged
batrick merged 1 commit into
ceph:mainfrom
batrick:i59335-2
Apr 16, 2026
Merged

batrick merged 1 commit into
ceph:mainfrom
batrick:i59335-2

Conversation

@batrick

@batrick batrick commented Apr 7, 2026 •

Copy link
Copy Markdown
Member
mon/MonClient: check stopping for auth request handling

When the MonClient is shutting down, it is no longer safe to
access MonClient::auth and other members. The AuthClient
methods should be checking the stopping flag in this case.

The key bit from the segfault backtrace (thanks Brad Hubbard!) is here:

        #13 0x00007f921ee23c40 in ProtocolV2::handle_auth_done (this=0x7f91cc0945f0, payload=...) at /usr/include/c++/12/bits/shared_ptr_base.h:1665
        #14 0x00007f921ee16a29 in ProtocolV2::run_continuation (this=0x7f91cc0945f0, continuation=...) at msg/./src/msg/async/ProtocolV2.cc:54
        #15 0x00007f921edee56e in std::function<void (char*, long)>::operator()(char*, long) const (__args#1=0, __args#0=<optimized out>, this=0x7f91cc0744d8) at /usr/include/c++/12/bits/std_function.h:591
        #16 AsyncConnection::process (this=0x7f91cc074140) at msg/./src/msg/async/AsyncConnection.cc:485
        #17 0x00007f921ee3300c in EventCenter::process_events (this=0x55efc9d0a058, timeout_microseconds=<optimized out>, working_dur=0x7f921a891d88) at msg/./src/msg/async/Event.cc:465
        #18 0x00007f921ee38bf9 in operator() (__closure=<optimized out>) at msg/./src/msg/async/Stack.cc:50
        #19 std::__invoke_impl<void, NetworkStack::add_thread(Worker*)::<lambda()>&> (__f=...) at /usr/include/c++/12/bits/invoke.h:61
        #20 std::__invoke_r<void, NetworkStack::add_thread(Worker*)::<lambda()>&> (__fn=...) at /usr/include/c++/12/bits/invoke.h:111
        #21 std::_Function_handler<void(), NetworkStack::add_thread(Worker*)::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/12/bits/std_function.h:29

0
#22 0x00007f921e81f253 in std::execute_native_thread_routine (__p=0x55efc9e9c5f0) at ../../../../../src/libstdc++-v3/src/c++11/thread.cc:82
#23 0x00007f921f5e8ac3 in start_thread (arg=) at ./nptl/pthread_create.c:442
#24 0x00007f921f67a8d0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

I originally thought this may be the issue causing [1] however that
turned out to be an issue caused by OpenSSL's use of atexit handlers.

I still think there is a bug here so I am continuing with this change.

[1] https://tracker.ceph.com/issues/59335

Fixes: https://tracker.ceph.com/issues/76017
Signed-off-by: Patrick Donnelly <[email protected]>

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.

@batrick

batrick commented Apr 7, 2026

Copy link
Copy Markdown
Member Author

Comment thread src/mon/MonClient.cc
}
monc_lock.lock();
timer.shutdown();
stopping = false;

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.

this might break get_monmap_and_config()'s retry loop, where it retries by calling shutdown() and then init() in a loop, when the config fetch times out. after the change above, init() does not reset stopping. so, on the second iteration, every auth callback returns early, and tick() also bails out early, so no monitor hunting begins and auth never completes.

in a3e82e9, Sage guarded the loop by stopping = true and stopping = false, so that the ops in the window between shutdown() and init() is marked unsafe (flagged by stopping). this applies to each iteration in the loop.

probably a simple fix would be to reset stopping at the top of init(), to unblock the retry path?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

probably a simple fix would be to reset stopping at the top of init(), to unblock the retry path?

This sounds reasonable.

@batrick
batrick force-pushed the i59335-2 branch 3 times, most recently from eae79c2 to 5bb1a21 Compare April 14, 2026 13:01
@batrick
batrick marked this pull request as ready for review April 14, 2026 13:01
@batrick

batrick commented Apr 14, 2026

Copy link
Copy Markdown
Member Author

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

This looks good to me, thanks Patrick!

Comment thread src/mon/MonClient.cc Resolved
@idryomov

idryomov commented Apr 15, 2026 •

Copy link
Copy Markdown
Contributor

I wonder if this happens to be addressing the root cause of rbd device unmap command sometimes spuriously outputting monclient: get_auth_request but no auth handler is set up error [1]. MonClient::get_auth_request() is now short circuited when stopping is set, but previously it was possible for it to run into a NULL auth pointer there?

[1] https://tracker.ceph.com/issues/74530

When the MonClient is shutting down, it is no longer safe to
access MonClient::auth and other members. The AuthClient
methods should be checking the stopping flag in this case.

The key bit from the segfault backtrace (thanks Brad Hubbard!) is here:

	#13 0x00007f921ee23c40 in ProtocolV2::handle_auth_done (this=0x7f91cc0945f0, payload=...) at /usr/include/c++/12/bits/shared_ptr_base.h:1665
	#14 0x00007f921ee16a29 in ProtocolV2::run_continuation (this=0x7f91cc0945f0, continuation=...) at msg/./src/msg/async/ProtocolV2.cc:54
	#15 0x00007f921edee56e in std::function<void (char*, long)>::operator()(char*, long) const (__args#1=0, __args#0=<optimized out>, this=0x7f91cc0744d8) at /usr/include/c++/12/bits/std_function.h:591
	#16 AsyncConnection::process (this=0x7f91cc074140) at msg/./src/msg/async/AsyncConnection.cc:485
	#17 0x00007f921ee3300c in EventCenter::process_events (this=0x55efc9d0a058, timeout_microseconds=<optimized out>, working_dur=0x7f921a891d88) at msg/./src/msg/async/Event.cc:465
	#18 0x00007f921ee38bf9 in operator() (__closure=<optimized out>) at msg/./src/msg/async/Stack.cc:50
	#19 std::__invoke_impl<void, NetworkStack::add_thread(Worker*)::<lambda()>&> (__f=...) at /usr/include/c++/12/bits/invoke.h:61
	#20 std::__invoke_r<void, NetworkStack::add_thread(Worker*)::<lambda()>&> (__fn=...) at /usr/include/c++/12/bits/invoke.h:111
	#21 std::_Function_handler<void(), NetworkStack::add_thread(Worker*)::<lambda()> >::_M_invoke(const std::_Any_data &) (__functor=...) at /usr/include/c++/12/bits/std_function.h:290
	#22 0x00007f921e81f253 in std::execute_native_thread_routine (__p=0x55efc9e9c5f0) at ../../../../../src/libstdc++-v3/src/c++11/thread.cc:82
	#23 0x00007f921f5e8ac3 in start_thread (arg=<optimized out>) at ./nptl/pthread_create.c:442
	#24 0x00007f921f67a8d0 in clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:81

I originally thought this may be the issue causing [1] however that
turned out to be an issue caused by OpenSSL's use of atexit handlers.

I still think there is a bug here so I am continuing with this change.

[1] https://tracker.ceph.com/issues/59335

Fixes: https://tracker.ceph.com/issues/76017
Signed-off-by: Patrick Donnelly <[email protected]>
@batrick
batrick requested a review from a team as a code owner April 16, 2026 12:09
@batrick

batrick commented Apr 16, 2026

Copy link
Copy Markdown
Member Author

I wonder if this happens to be addressing the root cause of rbd device unmap command sometimes spuriously outputting monclient: get_auth_request but no auth handler is set up error [1]. MonClient::get_auth_request() is now short circuited when stopping is set, but previously it was possible for it to run into a NULL auth pointer there?

[1] https://tracker.ceph.com/issues/74530

Yes, there's a window where the monc is shutdown but the messenger hasn't been stopped.

Since you're doing a diff on stdout/stderr this should probably fix that.

@batrick

batrick commented Apr 16, 2026

Copy link
Copy Markdown
Member Author

jenkins test windows

@batrick

batrick commented Apr 16, 2026

Copy link
Copy Markdown
Member Author

jenkins test docs

@batrick
batrick merged commit 8361950 into ceph:main Apr 16, 2026
6 checks passed
@batrick
batrick deleted the i59335-2 branch April 16, 2026 23:58
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