From: Xuehan Xu Date: Mon, 20 Feb 2023 06:07:26 +0000 (+0000) Subject: crimson/os/seastore: throttle concurrent transactions in seastore X-Git-Tag: v18.1.0~305^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b0b0fa1c1d087eacae6a8ff2c2d74a540ee913b3;p=ceph.git crimson/os/seastore: throttle concurrent transactions in seastore Fixes: https://tracker.ceph.com/issues/57215 Signed-off-by: Xuehan Xu --- diff --git a/src/common/options/crimson.yaml.in b/src/common/options/crimson.yaml.in index 5979801ff31..1f3cfd1bce1 100644 --- a/src/common/options/crimson.yaml.in +++ b/src/common/options/crimson.yaml.in @@ -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 diff --git a/src/crimson/os/seastore/seastore.cc b/src/crimson/os/seastore/seastore.cc index d26ab8b2de2..6680f52a80a 100644 --- a/src/crimson/os/seastore/seastore.cc +++ b/src/crimson/os/seastore/seastore.cc @@ -123,7 +123,9 @@ SeaStore::SeaStore( device(std::move(dev)), max_object_size( get_conf("seastore_default_max_object_size")), - is_test(is_test) + is_test(is_test), + throttler( + get_conf("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() diff --git a/src/crimson/os/seastore/seastore.h b/src/crimson/os/seastore/seastore.h index 4e83db040ae..bc4cce027f7 100644 --- a/src/crimson/os/seastore/seastore.h +++ b/src/crimson/os/seastore/seastore.h @@ -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), [this, op_type](auto &ctx, auto &f) { - return ctx.transaction->get_handle().take_collection_lock( - static_cast(*(ctx.ch)).ordering_lock - ).then([&, this] { + return throttler.get(1).then([&ctx] { + return ctx.transaction->get_handle().take_collection_lock( + static_cast(*(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(