From dee230c26d4fe894cb0d700e85cee37cd5c00a6c Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Thu, 15 Aug 2024 13:58:30 -0400 Subject: [PATCH] rgw/notify: process_queue() constructs wait tokens when spawning process_queue() spawns several coroutines, then waits on a tokens_waiter until all of them complete but spawned coroutines don't start immediately. if we call waiter.async_wait() before any of the coroutine functions get spawned, it will find `pending_tokens == 0` and return immediately instead of constructing each token inside the spawned coroutine function, construct them outside of spawn and capture them in the lambda to extend their lifetime until the coroutine's completion Signed-off-by: Casey Bodley --- src/rgw/driver/rados/rgw_notify.cc | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/rgw/driver/rados/rgw_notify.cc b/src/rgw/driver/rados/rgw_notify.cc index 6b1dd9651f03..3f576120a8ca 100644 --- a/src/rgw/driver/rados/rgw_notify.cc +++ b/src/rgw/driver/rados/rgw_notify.cc @@ -472,11 +472,10 @@ private: entries_persistency_tracker& notifs_persistency_tracker = topics_persistency_tracker[queue_name]; boost::asio::spawn(yield, std::allocator_arg, make_stack_allocator(), [this, ¬ifs_persistency_tracker, &queue_name, entry_idx, - total_entries, &end_marker, &remove_entries, &has_error, &waiter, - &entry, &needs_migration_vector, + total_entries, &end_marker, &remove_entries, &has_error, + token = waiter.make_token(), &entry, &needs_migration_vector, push_endpoint = push_endpoint.get(), &topic_info](boost::asio::yield_context yield) { - const auto token = waiter.make_token(); auto& persistency_tracker = notifs_persistency_tracker[entry.marker]; auto result = process_entry(this->get_cct()->_conf, persistency_tracker, -- 2.47.3