From fb5d01a602526fb091c14a06bbd4ddb7342a6091 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Mon, 5 Feb 2024 12:35:49 +0530 Subject: [PATCH] rgw/d4n: fixing the 'get' call hanging issues and Operation Canceled errors, by wrapping async_exec call in boost::asio::dispatch() call. Signed-off-by: Casey Bodley --- src/rgw/driver/d4n/d4n_directory.cc | 11 +++++++---- src/rgw/driver/d4n/d4n_policy.cc | 10 ++++++---- src/rgw/rgw_redis_driver.cc | 11 +++++++---- 3 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/rgw/driver/d4n/d4n_directory.cc b/src/rgw/driver/d4n/d4n_directory.cc index a3dbc0b3bf9..2e9f9ad80cf 100644 --- a/src/rgw/driver/d4n/d4n_directory.cc +++ b/src/rgw/driver/d4n/d4n_directory.cc @@ -8,15 +8,18 @@ namespace rgw { namespace d4n { // initiate a call to async_exec() on the connection's executor struct initiate_exec { std::shared_ptr conn; - boost::redis::request req; using executor_type = boost::redis::connection::executor_type; executor_type get_executor() const noexcept { return conn->get_executor(); } template - void operator()(Handler handler, Response& resp) + void operator()(Handler handler, const boost::redis::request& req, Response& resp) { - conn->async_exec(req, resp, boost::asio::consign(std::move(handler), conn)); + auto h = boost::asio::consign(std::move(handler), conn); + return boost::asio::dispatch(get_executor(), + [c = conn, &req, &resp, h = std::move(h)] { + return c->async_exec(req, resp, std::move(h)); + }); } }; @@ -27,7 +30,7 @@ auto async_exec(std::shared_ptr conn, { return boost::asio::async_initiate( - initiate_exec{std::move(conn), req}, token, resp); + initiate_exec{std::move(conn)}, token, req, resp); } template diff --git a/src/rgw/driver/d4n/d4n_policy.cc b/src/rgw/driver/d4n/d4n_policy.cc index b2d4a725cac..5adba67db01 100644 --- a/src/rgw/driver/d4n/d4n_policy.cc +++ b/src/rgw/driver/d4n/d4n_policy.cc @@ -10,15 +10,17 @@ namespace rgw { namespace d4n { // initiate a call to async_exec() on the connection's executor struct initiate_exec { std::shared_ptr conn; - boost::redis::request req; using executor_type = boost::redis::connection::executor_type; executor_type get_executor() const noexcept { return conn->get_executor(); } template - void operator()(Handler handler, Response& resp) + void operator()(Handler handler, const boost::redis::request& req, Response& resp) { - conn->async_exec(req, resp, boost::asio::consign(std::move(handler), conn)); + auto h = boost::asio::consign(std::move(handler), conn); + return boost::asio::dispatch(get_executor(), [c=conn, &req, &resp, h=std::move(h)] { + c->async_exec(req, resp, std::move(h)); + }); } }; @@ -29,7 +31,7 @@ auto async_exec(std::shared_ptr conn, { return boost::asio::async_initiate( - initiate_exec{std::move(conn), req}, token, resp); + initiate_exec{std::move(conn)}, token, req, resp); } template diff --git a/src/rgw/rgw_redis_driver.cc b/src/rgw/rgw_redis_driver.cc index caad53a2426..554e68ad17f 100644 --- a/src/rgw/rgw_redis_driver.cc +++ b/src/rgw/rgw_redis_driver.cc @@ -26,15 +26,18 @@ std::list build_attrs(const rgw::sal::Attrs& binary) // initiate a call to async_exec() on the connection's executor struct initiate_exec { std::shared_ptr conn; - boost::redis::request req; using executor_type = boost::redis::connection::executor_type; executor_type get_executor() const noexcept { return conn->get_executor(); } template - void operator()(Handler handler, Response& resp) + void operator()(Handler handler, const boost::redis::request& req, Response& resp) { - conn->async_exec(req, resp, boost::asio::consign(std::move(handler), conn)); + auto h = boost::asio::consign(std::move(handler), conn); + return boost::asio::dispatch(get_executor(), + [c=conn, &req, &resp, h=std::move(h)] { + return c->async_exec(req, resp, std::move(h)); + }); } }; @@ -45,7 +48,7 @@ auto async_exec(std::shared_ptr conn, { return boost::asio::async_initiate( - initiate_exec{std::move(conn), req}, token, resp); + initiate_exec{std::move(conn)}, token, req, resp); } template -- 2.47.3