]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mon/MonClient: post version request completions outside of monc_lock 64898/head
authorIlya Dryomov <idryomov@gmail.com>
Thu, 21 Aug 2025 19:39:29 +0000 (21:39 +0200)
committerAdam C. Emerson <aemerson@redhat.com>
Sun, 24 Aug 2025 17:35:48 +0000 (13:35 -0400)
commit9cb9d0c7d55cf053d82127810c439896e6ddb61e
treef92ee6674716a267ac18d1f75c5c94408d1268d5
parent46cb1815f01fd1e10fc9d3c7de30ce18352ac2d7
mon/MonClient: post version request completions outside of monc_lock

dispatch() is allowed to invoke the completion object in the current
thread, before control returns from dispatch().  This isn't desirable
when it comes to discarding version requests in MonClient::shutdown()
and MonClient::_reopen_session() because completion objects could then
be invoked under monc_lock.  In case of MonClient::_reopen_session() in
particular, this leads to an attempt to acquire monc_lock once again in
MonClient::get_version() on a retry due to monc_errc::session_reset
that is converted to errc::resource_unavailable_try_again:

  MonClient::ms_handle_reset
    < takes monc_lock >
    MonClient::_reopen_session
      < invokes the completion object via dispatch() with ec == monc_errc::session_reset >
      Objecter::CB_Objecter_GetVersion::operator() [ ec == errc::resource_unavailable_try_again ]
        Objecter::_wait_for_latest_osdmap
          MonClient::get_version
            < attempts to take monc_lock in the body of the lambda >

The end result is either a lockup or some form of undefined behavior.
The best possible outcome here is an exception (std::system_error with
"Resource deadlock avoided" error) and a successive call to
std::terminate().

This is a regression introduced in commit e81d4eae4e76 ("common/async:
Update `use_blocked` for newer asio").  Revert to posting version
request completions for the error cases in a way that is uniform with
the success case in MonClient::handle_get_version_reply().

Fixes: https://tracker.ceph.com/issues/72692
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
(cherry picked from commit bd449f0ac823413a55069e3df9e163a4b4adbebd)
Signed-off-by: Adam C. Emerson <aemerson@redhat.com>
src/mon/MonClient.cc