Files
scylladb/init.hh
Tomasz Grabiec 751fdc9f6c Merge "Fix window during init where waiting for a feature can be ignored" from Avi
storage_service keeps a bunch of "feature" variables, indicating cluster-wide
supported features, and has the ability to wait until the entire cluster supports
a given feature.

The propagation of features depends on gossip, but gossip is initialized after
storage_service, so the current code late-initializes the features. However, that
means that whoever waits on a feature between storage_service initialization and
gossip initialization loses their wait entry. In #3952, we have proof that this
in fact happens.

Fix this by removing the circular dependency. We now store features in a new
service, feature_service, that is started before both gossip and storage_service.
Gossip updates feature_service while storage_service reads for it.

Fixes #3953.

* https://github.com/avikivity/3953/v4.1:
  storage_service: deinline enable_all_features()
  gossiper: keep features registered
  tests/gossip: switch to seastar::thread
  storage_service: deinline init/deinit functions
  gossiper: split feature storage into a new feature_service
  gossiper: maybe enable features after start_gossiping()
  storage_service: fix gap when feature::when_enabled() doesn't work

(cherry picked from commit 6012a63660)
2019-03-20 17:25:35 +08:00

105 lines
3.6 KiB
C++

/*
* Copyright (C) 2015 ScyllaDB
*/
/*
* This file is part of Scylla.
*
* Scylla is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Scylla is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Scylla. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include <seastar/core/sstring.hh>
#include <seastar/core/future.hh>
#include <seastar/core/distributed.hh>
#include "auth/service.hh"
#include "db/config.hh"
#include "db/system_distributed_keyspace.hh"
#include "database.hh"
#include "log.hh"
#include "seastarx.hh"
namespace db {
class extensions;
}
namespace gms {
class feature_service;
}
extern logging::logger startlog;
class bad_configuration_error : public std::exception {};
void init_storage_service(distributed<database>& db, sharded<auth::service>&, sharded<db::system_distributed_keyspace>&, sharded<gms::feature_service>&);
struct init_scheduling_config {
scheduling_group streaming;
scheduling_group statement;
scheduling_group gossip;
};
void init_ms_fd_gossiper(sharded<gms::feature_service>& features
, sstring listen_address
, uint16_t storage_port
, uint16_t ssl_storage_port
, bool tcp_nodelay_inter_dc
, sstring ms_encrypt_what
, sstring ms_trust_store
, sstring ms_cert
, sstring ms_key
, sstring ms_tls_prio
, bool ms_client_auth
, sstring ms_compress
, db::seed_provider_type seed_provider
, size_t available_memory
, init_scheduling_config scheduling_config
, sstring cluster_name = "Test Cluster"
, double phi = 8
, bool sltba = false);
/**
* Very simplistic config registry. Allows hooking in a config object
* to the "main" sequence.
*/
class configurable {
public:
configurable() {
// We auto register. Not that like cycle is assumed to be forever
// and scope should be managed elsewhere.
register_configurable(*this);
}
virtual ~configurable()
{}
// Hook to add command line options and/or add main config options
virtual void append_options(db::config&, boost::program_options::options_description_easy_init&)
{};
// Called after command line is parsed and db/config populated.
// Hooked config can for example take this oppurtunity to load any file(s).
virtual future<> initialize(const boost::program_options::variables_map&) {
return make_ready_future();
}
virtual future<> initialize(const boost::program_options::variables_map& map, const db::config& cfg, db::extensions& exts) {
return initialize(map);
}
// visible for testing
static std::vector<std::reference_wrapper<configurable>>& configurables();
static future<> init_all(const boost::program_options::variables_map&, const db::config&, db::extensions&);
static future<> init_all(const db::config&, db::extensions&);
static void append_all(db::config&, boost::program_options::options_description_easy_init&);
private:
static void register_configurable(configurable &);
};