]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw/rados: RGWReshardWait warns about blocking
authorCasey Bodley <cbodley@redhat.com>
Thu, 20 Jun 2024 20:28:02 +0000 (16:28 -0400)
committerCasey Bodley <cbodley@redhat.com>
Tue, 2 Jul 2024 20:40:50 +0000 (16:40 -0400)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/driver/rados/rgw_rados.cc
src/rgw/driver/rados/rgw_reshard.cc
src/rgw/driver/rados/rgw_reshard.h
src/test/rgw/test_rgw_reshard_wait.cc

index c307b3a4ed807d3bbc9569dff24ae8954713b935..2b9937b46146f60b8434814268d3b2994b057a22 100644 (file)
@@ -7776,7 +7776,7 @@ int RGWRados::block_while_resharding(RGWRados::BucketShard *bs,
       } // if taking of lock succeeded
     } // block to encapsulate recovery from incomplete reshard
 
-    ret = reshard_wait->wait(y);
+    ret = reshard_wait->wait(dpp, y);
     if (ret < 0) {
       ldpp_dout(dpp, 0) << __func__ <<
        " ERROR: bucket is still resharding, please retry" << dendl;
index 3d38aa29aa034489418607b3bcd0bb774d06f8aa..9bd4aad89a1b5e6dc94cca5979fd44e597d2c947 100644 (file)
@@ -7,6 +7,7 @@
 
 #include "rgw_zone.h"
 #include "driver/rados/rgw_bucket.h"
+#include "rgw_asio_thread.h"
 #include "rgw_reshard.h"
 #include "rgw_sal.h"
 #include "rgw_sal_rados.h"
@@ -1261,7 +1262,7 @@ int RGWReshard::clear_bucket_resharding(const DoutPrefixProvider *dpp, const str
   return 0;
 }
 
-int RGWReshardWait::wait(optional_yield y)
+int RGWReshardWait::wait(const DoutPrefixProvider* dpp, optional_yield y)
 {
   std::unique_lock lock(mutex);
 
@@ -1285,6 +1286,7 @@ int RGWReshardWait::wait(optional_yield y)
     waiters.erase(waiters.iterator_to(waiter));
     return -ec.value();
   }
+  maybe_warn_about_blocking(dpp);
 
   cond.wait_for(lock, duration);
 
index 818bf2164955e1cc5a1a026cff746a2e94b74247..a2097318827f3b568df5b2c1c7fe0e7e095faf8e 100644 (file)
@@ -266,7 +266,7 @@ public:
   ~RGWReshardWait() {
     ceph_assert(going_down);
   }
-  int wait(optional_yield y);
+  int wait(const DoutPrefixProvider* dpp, optional_yield y);
   // unblock any threads waiting on reshard
   void stop();
 };
index 058828b956c88e358a6e3103dae3a667cb91a2ab..91fc4324129c923520252ca1ebb911654c213162 100644 (file)
@@ -23,10 +23,11 @@ using Clock = RGWReshardWait::Clock;
 TEST(ReshardWait, wait_block)
 {
   constexpr ceph::timespan wait_duration = 10ms;
+  const auto dpp = NoDoutPrefix{g_ceph_context, ceph_subsys_rgw};
   RGWReshardWait waiter(wait_duration);
 
   const auto start = Clock::now();
-  EXPECT_EQ(0, waiter.wait(null_yield));
+  EXPECT_EQ(0, waiter.wait(&dpp, null_yield));
   const ceph::timespan elapsed = Clock::now() - start;
 
   EXPECT_LE(wait_duration, elapsed); // waited at least 10ms
@@ -37,16 +38,17 @@ TEST(ReshardWait, stop_block)
 {
   constexpr ceph::timespan short_duration = 10ms;
   constexpr ceph::timespan long_duration = 10s;
+  const auto dpp = NoDoutPrefix{g_ceph_context, ceph_subsys_rgw};
 
   RGWReshardWait long_waiter(long_duration);
   RGWReshardWait short_waiter(short_duration);
 
   const auto start = Clock::now();
-  std::thread thread([&long_waiter] {
-    EXPECT_EQ(-ECANCELED, long_waiter.wait(null_yield));
+  std::thread thread([&dpp, &long_waiter] {
+    EXPECT_EQ(-ECANCELED, long_waiter.wait(&dpp, null_yield));
   });
 
-  EXPECT_EQ(0, short_waiter.wait(null_yield));
+  EXPECT_EQ(0, short_waiter.wait(&dpp, null_yield));
 
   long_waiter.stop(); // cancel long waiter
 
@@ -65,11 +67,12 @@ void rethrow(std::exception_ptr eptr) {
 TEST(ReshardWait, wait_yield)
 {
   constexpr ceph::timespan wait_duration = 50ms;
+  const auto dpp = NoDoutPrefix{g_ceph_context, ceph_subsys_rgw};
   RGWReshardWait waiter(wait_duration);
 
   boost::asio::io_context context;
   boost::asio::spawn(context, [&] (boost::asio::yield_context yield) {
-      EXPECT_EQ(0, waiter.wait(yield));
+      EXPECT_EQ(0, waiter.wait(&dpp, yield));
     }, rethrow);
 
   const auto start = Clock::now();
@@ -88,6 +91,7 @@ TEST(ReshardWait, stop_yield)
 {
   constexpr ceph::timespan short_duration = 50ms;
   constexpr ceph::timespan long_duration = 10s;
+  const auto dpp = NoDoutPrefix{g_ceph_context, ceph_subsys_rgw};
 
   RGWReshardWait long_waiter(long_duration);
   RGWReshardWait short_waiter(short_duration);
@@ -95,14 +99,14 @@ TEST(ReshardWait, stop_yield)
   boost::asio::io_context context;
   boost::asio::spawn(context,
     [&] (boost::asio::yield_context yield) {
-      EXPECT_EQ(-ECANCELED, long_waiter.wait(yield));
+      EXPECT_EQ(-ECANCELED, long_waiter.wait(&dpp, yield));
     }, rethrow);
 
   const auto start = Clock::now();
   EXPECT_EQ(1u, context.poll()); // spawn
   EXPECT_FALSE(context.stopped());
 
-  EXPECT_EQ(0, short_waiter.wait(null_yield));
+  EXPECT_EQ(0, short_waiter.wait(&dpp, null_yield));
 
   long_waiter.stop(); // cancel long waiter
 
@@ -119,6 +123,7 @@ TEST(ReshardWait, stop_multiple)
 {
   constexpr ceph::timespan short_duration = 50ms;
   constexpr ceph::timespan long_duration = 10s;
+  const auto dpp = NoDoutPrefix{g_ceph_context, ceph_subsys_rgw};
 
   RGWReshardWait long_waiter(long_duration);
   RGWReshardWait short_waiter(short_duration);
@@ -126,8 +131,8 @@ TEST(ReshardWait, stop_multiple)
   // spawn 4 threads
   std::vector<std::thread> threads;
   {
-    auto sync_waiter([&long_waiter] {
-      EXPECT_EQ(-ECANCELED, long_waiter.wait(null_yield));
+    auto sync_waiter([&dpp, &long_waiter] {
+      EXPECT_EQ(-ECANCELED, long_waiter.wait(&dpp, null_yield));
     });
     threads.emplace_back(sync_waiter);
     threads.emplace_back(sync_waiter);
@@ -138,7 +143,7 @@ TEST(ReshardWait, stop_multiple)
   boost::asio::io_context context;
   {
     auto async_waiter = [&] (boost::asio::yield_context yield) {
-        EXPECT_EQ(-ECANCELED, long_waiter.wait(yield));
+        EXPECT_EQ(-ECANCELED, long_waiter.wait(&dpp, yield));
       };
     boost::asio::spawn(context, async_waiter, rethrow);
     boost::asio::spawn(context, async_waiter, rethrow);
@@ -150,7 +155,7 @@ TEST(ReshardWait, stop_multiple)
   EXPECT_EQ(4u, context.poll()); // spawn
   EXPECT_FALSE(context.stopped());
 
-  EXPECT_EQ(0, short_waiter.wait(null_yield));
+  EXPECT_EQ(0, short_waiter.wait(&dpp, null_yield));
 
   long_waiter.stop(); // cancel long waiter