]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
common/async: async_cond::notify/cancel must post to handler's associated executor 69314/head
authorShilpa Jagannath <smanjara@redhat.com>
Fri, 5 Jun 2026 18:42:35 +0000 (14:42 -0400)
committerShilpa Jagannath <smanjara@redhat.com>
Tue, 9 Jun 2026 19:13:04 +0000 (15:13 -0400)
RGWDeleteMultiObj spawns child coroutines via spawn_throttle to delete
objects in parallel. each child coroutine carries the connection strand
as its associated executor, serializing concurrent operations on shared
state like the response formatter and ops_log_entries.

but in multisite env, concurrent deletions in the same bucket shard
contend on async_cond in RGWDataChangesLog::add_entry(). when notify()
fires, waiting coroutines resume on the raw io_context executor
instead of their connection strand, breaking the serialization that prevents data
races in send_partial_response()

any_completion_handler doesn't support post(). so post() to the
default executor and dispatch to the associated executor from there

Signed-off-by: Shilpa Jagannath <smanjara@redhat.com>
src/common/async/async_cond.h

index 0ad87f75cd0904265b0ac59faf6915489d956755..53869910b447eeba75f1d3597909a2c299d60da1 100644 (file)
@@ -28,6 +28,7 @@
 #include <boost/asio/any_io_executor.hpp>
 #include <boost/asio/append.hpp>
 #include <boost/asio/async_result.hpp>
+#include <boost/asio/bind_executor.hpp>
 #include <boost/asio/consign.hpp>
 #include <boost/asio/error.hpp>
 #include <boost/asio/execution_context.hpp>
@@ -58,8 +59,8 @@ class async_cond : public service_list_base_hook {
 
   std::mutex m;
   std::vector<std::pair<
-    boost::asio::any_completion_handler<
-    void(boost::system::error_code)>, std::unique_lock<BasicLockable>*>> handlers;
+    boost::asio::any_completion_handler<void(boost::system::error_code)>,
+    std::unique_lock<BasicLockable>*>> handlers;
 
   void service_shutdown() {
     std::unique_lock l(m);
@@ -135,12 +136,13 @@ public:
       handlers.resize(0);
       l.unlock();
       for (auto&& [handler, lock] : workhandlers) {
+       auto ex = asio::get_associated_executor(handler, executor);
        asio::post(executor,
-                  [handler = std::move(handler), lock = lock]() mutable {
-                    lock->lock();
-                    std::move(handler)(sys::error_code{});
-                  });
-
+                  asio::bind_executor(ex,
+                    [handler = std::move(handler), lock = lock]() mutable {
+                      lock->lock();
+                      std::move(handler)(sys::error_code{});
+                    }));
       }
     }
   }
@@ -157,12 +159,13 @@ public:
       handlers.resize(0);
       l.unlock();
       for (auto&& [handler, lock] : workhandlers) {
+       auto ex = asio::get_associated_executor(handler, executor);
        asio::post(executor,
-                  [handler = std::move(handler), lock = lock]() mutable {
-                    lock->lock();
-                    std::move(handler)(asio::error::operation_aborted);
-                  });
-
+                  asio::bind_executor(ex,
+                    [handler = std::move(handler), lock = lock]() mutable {
+                      lock->lock();
+                      std::move(handler)(asio::error::operation_aborted);
+                    }));
       }
     }
   }