]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
crimson/os/seastore: throttle concurrent transactions in seastore
authorXuehan Xu <xxhdx1985126@gmail.com>
Mon, 20 Feb 2023 06:07:26 +0000 (06:07 +0000)
committerXuehan Xu <xxhdx1985126@gmail.com>
Mon, 20 Feb 2023 07:04:03 +0000 (07:04 +0000)
Fixes: https://tracker.ceph.com/issues/57215
Signed-off-by: Xuehan Xu <xxhdx1985126@gmail.com>
src/common/options/crimson.yaml.in
src/crimson/os/seastore/seastore.cc
src/crimson/os/seastore/seastore.h

index 5979801ff315f8223439941c7afa8de2db90070d..1f3cfd1bce1f91b1dbf95503b703a177f9d2da44 100644 (file)
@@ -87,3 +87,8 @@ options:
   level: advanced
   desc: split extent if ratio of total extent size to write size exceeds this value
   default: 1.25
+- name: seastore_max_concurrent_transactions
+  type: uint
+  level: advanced
+  desc: maximum concurrent transactions that seastore allows
+  default: 8
index d26ab8b2de255a845d40655f477fcb6f3a885aa5..6680f52a80a6c7252875d29b91ca2f1937af4f19 100644 (file)
@@ -123,7 +123,9 @@ SeaStore::SeaStore(
     device(std::move(dev)),
     max_object_size(
       get_conf<uint64_t>("seastore_default_max_object_size")),
-    is_test(is_test)
+    is_test(is_test),
+    throttler(
+      get_conf<uint64_t>("seastore_max_concurrent_transactions"))
 {
   register_metrics();
 }
@@ -161,6 +163,19 @@ void SeaStore::register_metrics()
       }
     );
   }
+
+  metrics.add_group(
+    "seastore",
+    {
+      sm::make_gauge(
+       "concurrent_transactions",
+       [this] {
+         return throttler.get_current();
+       },
+       sm::description("transactions that are running inside seastore")
+      )
+    }
+  );
 }
 
 seastar::future<> SeaStore::stop()
index 4e83db040ae7e6cbbde8396e02733bd6157e9372..bc4cce027f78a5b28d5f9b89c5860604e2778fe6 100644 (file)
@@ -16,6 +16,7 @@
 #include "include/uuid.h"
 
 #include "os/Transaction.h"
+#include "crimson/common/throttle.h"
 #include "crimson/os/futurized_collection.h"
 #include "crimson/os/futurized_store.h"
 
@@ -232,9 +233,11 @@ private:
        transaction_manager->create_transaction(src, tname)),
       std::forward<F>(f),
       [this, op_type](auto &ctx, auto &f) {
-       return ctx.transaction->get_handle().take_collection_lock(
-         static_cast<SeastoreCollection&>(*(ctx.ch)).ordering_lock
-       ).then([&, this] {
+       return throttler.get(1).then([&ctx] {
+         return ctx.transaction->get_handle().take_collection_lock(
+           static_cast<SeastoreCollection&>(*(ctx.ch)).ordering_lock
+         );
+       }).then([&, this] {
          return repeat_eagain([&, this] {
            ctx.reset_preserve_handle(*transaction_manager);
            return std::invoke(f, ctx);
@@ -247,6 +250,8 @@ private:
        }).then([this, op_type, &ctx] {
          add_latency_sample(op_type,
              std::chrono::steady_clock::now() - ctx.begin_timestamp);
+       }).finally([this] {
+         throttler.put();
        });
       }
     );
@@ -336,6 +341,8 @@ private:
   CollectionManagerRef collection_manager;
   OnodeManagerRef onode_manager;
 
+  common::Throttle throttler;
+
   using tm_iertr = TransactionManager::base_iertr;
   using tm_ret = tm_iertr::future<>;
   tm_ret _do_transaction_step(