]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
rgw: add is_asio_thread to warn on blocking librados calls
authorCasey Bodley <cbodley@redhat.com>
Thu, 30 Nov 2017 18:10:20 +0000 (13:10 -0500)
committerCasey Bodley <cbodley@redhat.com>
Tue, 27 Nov 2018 17:30:25 +0000 (12:30 -0500)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_asio_frontend.cc
src/rgw/rgw_tools.cc
src/rgw/rgw_tools.h

index c77ac4a6f815fe9a82dd8c3e429d2387b97d548f..3e08aa62ac57b48080f61573a626f69096277201 100644 (file)
@@ -558,6 +558,8 @@ int AsioFrontend::run()
 
   for (int i = 0; i < thread_count; i++) {
     threads.emplace_back([=] {
+      // request warnings on synchronous librados calls in this thread
+      is_asio_thread = true;
       boost::system::error_code ec;
       context.run(ec);
     });
index 66829d98fc97d28365410da0bc772250c66ce2f7..0d64cf19fdc5a11499f4a69156ba4bd19ff2d615 100644 (file)
@@ -119,6 +119,8 @@ int rgw_delete_system_obj(RGWRados *rgwstore, const rgw_pool& pool, const string
                .remove();
 }
 
+thread_local bool is_asio_thread = false;
+
 int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid,
                       librados::ObjectReadOperation *op, bufferlist* pbl,
                       optional_yield y)
@@ -136,6 +138,10 @@ int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid,
     }
     return -ec.value();
   }
+  // work on asio threads should be asynchronous, so warn when they block
+  if (is_asio_thread) {
+    dout(20) << "WARNING: blocking librados call" << dendl;
+  }
 #endif
   return ioctx.operate(oid, op, nullptr);
 }
@@ -151,6 +157,9 @@ int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid,
     librados::async_operate(context, ioctx, oid, op, 0, yield[ec]);
     return -ec.value();
   }
+  if (is_asio_thread) {
+    dout(20) << "WARNING: blocking librados call" << dendl;
+  }
 #endif
   return ioctx.operate(oid, op);
 }
index be37634205f8e4a70d65a6ae6cb240e6052e85ae..a932084cd781f296f7ada46c26d7d5b90afb495c 100644 (file)
@@ -31,6 +31,10 @@ const char *rgw_find_mime_by_ext(string& ext);
 void rgw_filter_attrset(map<string, bufferlist>& unfiltered_attrset, const string& check_prefix,
                         map<string, bufferlist> *attrset);
 
+/// indicates whether the current thread is in boost::asio::io_context::run(),
+/// used to log warnings if synchronous librados calls are made
+extern thread_local bool is_asio_thread;
+
 /// perform the rados operation, using the yield context when given
 int rgw_rados_operate(librados::IoCtx& ioctx, const std::string& oid,
                       librados::ObjectReadOperation *op, bufferlist* pbl,