mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
The feature listener callbacks are waited upon to finish in the middle of the cluster joining process. I particular -- before actually joining the cluster the format should have being selected. For that there's a .sync() method that locks the semaphore thus making sure that any update is finished and it's called right after the wait_for_gossip_to_settle() finishes. However, features are enabled inside the wait_for_gossip_to_settle() in a seastar::async() context that's also waited upon to finish. This waiting makes it possible for any feature listener to .get() any of its futures that should be resolved until gossip is settled. Said that, the format selection barrier can be moved -- instead of waiting on the semaphore, the respective part of the selection code can be .get()-ed (it all runs in async context). One thing to care about -- the remainder should continue running with the gate held. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
70 lines
1.6 KiB
C++
70 lines
1.6 KiB
C++
/*
|
|
* Copyright (C) 2020-present ScyllaDB
|
|
*
|
|
*/
|
|
|
|
/*
|
|
* SPDX-License-Identifier: AGPL-3.0-or-later
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <seastar/core/semaphore.hh>
|
|
#include <seastar/core/future.hh>
|
|
#include <seastar/core/gate.hh>
|
|
#include <seastar/core/sharded.hh>
|
|
#include "sstables/version.hh"
|
|
#include "gms/feature.hh"
|
|
|
|
using namespace seastar;
|
|
|
|
namespace replica {
|
|
class database;
|
|
}
|
|
|
|
namespace gms {
|
|
class gossiper;
|
|
class feature_service;
|
|
}
|
|
|
|
namespace db {
|
|
|
|
class sstables_format_selector;
|
|
|
|
class feature_enabled_listener : public gms::feature::listener {
|
|
sstables_format_selector& _selector;
|
|
sstables::sstable_version_types _format;
|
|
|
|
public:
|
|
feature_enabled_listener(sstables_format_selector& s, sstables::sstable_version_types format)
|
|
: _selector(s)
|
|
, _format(format)
|
|
{ }
|
|
void on_enabled() override;
|
|
};
|
|
|
|
class sstables_format_selector {
|
|
gms::gossiper& _gossiper;
|
|
sharded<gms::feature_service>& _features;
|
|
sharded<replica::database>& _db;
|
|
seastar::named_semaphore _sem = {1, named_semaphore_exception_factory{"feature listeners"}};
|
|
seastar::gate _sel;
|
|
|
|
feature_enabled_listener _md_feature_listener;
|
|
feature_enabled_listener _me_feature_listener;
|
|
|
|
sstables::sstable_version_types _selected_format = sstables::sstable_version_types::mc;
|
|
future<> select_format(sstables::sstable_version_types new_format);
|
|
future<> read_sstables_format();
|
|
|
|
public:
|
|
sstables_format_selector(gms::gossiper& g, sharded<gms::feature_service>& f, sharded<replica::database>& db);
|
|
|
|
future<> start();
|
|
future<> stop();
|
|
|
|
future<> maybe_select_format(sstables::sstable_version_types new_format);
|
|
};
|
|
|
|
} // namespace sstables
|