mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-29 11:10:40 +00:00
snapshots: Move ops gate from storage_service
Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -40,7 +40,6 @@
|
||||
|
||||
#include <boost/range/adaptors.hpp>
|
||||
#include "db/snapshot-ctl.hh"
|
||||
#include "service/storage_service.hh"
|
||||
|
||||
namespace db {
|
||||
|
||||
@@ -58,8 +57,7 @@ future<> check_snapshot_not_exist(database& db, sstring ks_name, sstring name) {
|
||||
|
||||
template <typename Func>
|
||||
std::result_of_t<Func()> snapshot_ctl::run_snapshot_modify_operation(Func&& f) {
|
||||
auto& ss = service::get_storage_service();
|
||||
return with_gate(ss.local()._snapshot_ops, [f = std::move(f), this] () {
|
||||
return with_gate(_ops, [f = std::move(f), this] () {
|
||||
return container().invoke_on(0, [f = std::move(f)] (snapshot_ctl& snap) mutable {
|
||||
return with_lock(snap._lock.for_write(), std::move(f));
|
||||
});
|
||||
@@ -68,8 +66,7 @@ std::result_of_t<Func()> snapshot_ctl::run_snapshot_modify_operation(Func&& f) {
|
||||
|
||||
template <typename Func>
|
||||
std::result_of_t<Func()> snapshot_ctl::run_snapshot_list_operation(Func&& f) {
|
||||
auto& ss = service::get_storage_service();
|
||||
return with_gate(ss.local()._snapshot_ops, [f = std::move(f), this] () {
|
||||
return with_gate(_ops, [f = std::move(f), this] () {
|
||||
return container().invoke_on(0, [f = std::move(f)] (snapshot_ctl& snap) mutable {
|
||||
return with_lock(snap._lock.for_read(), std::move(f));
|
||||
});
|
||||
|
||||
@@ -58,6 +58,10 @@ public:
|
||||
};
|
||||
explicit snapshot_ctl(sharded<database>& db) : _db(db) {}
|
||||
|
||||
future<> stop() {
|
||||
return _ops.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes the snapshot for all keyspaces. A snapshot name must be specified.
|
||||
*
|
||||
@@ -106,6 +110,7 @@ public:
|
||||
private:
|
||||
sharded<database>& _db;
|
||||
seastar::rwlock _lock;
|
||||
seastar::gate _ops;
|
||||
|
||||
template <typename Func>
|
||||
std::result_of_t<Func()> run_snapshot_modify_operation(Func&&);
|
||||
|
||||
3
main.cc
3
main.cc
@@ -1060,9 +1060,6 @@ int main(int ac, char** av) {
|
||||
auth_service.stop().get();
|
||||
});
|
||||
|
||||
auto stop_snapshots = defer_verbose_shutdown("snapshots", [] {
|
||||
service::get_storage_service().invoke_on_all(&service::storage_service::snapshots_close).get();
|
||||
});
|
||||
|
||||
snapshot_ctl.start(std::ref(db)).get();
|
||||
auto stop_snapshot_ctl = defer_verbose_shutdown("snapshots", [&snapshot_ctl] {
|
||||
|
||||
@@ -233,14 +233,7 @@ private:
|
||||
bool _joined = false;
|
||||
|
||||
public:
|
||||
seastar::gate _snapshot_ops;
|
||||
|
||||
enum class mode { STARTING, NORMAL, JOINING, LEAVING, DECOMMISSIONED, MOVING, DRAINING, DRAINED };
|
||||
|
||||
future<> snapshots_close() {
|
||||
return _snapshot_ops.close();
|
||||
}
|
||||
|
||||
private:
|
||||
mode _operation_mode = mode::STARTING;
|
||||
friend std::ostream& operator<<(std::ostream& os, const mode& mode);
|
||||
|
||||
Reference in New Issue
Block a user