mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-31 18:24:25 +03:00
Pass initial position when loading the provider
Having initial position as a part of server_state does not allow restarting the provider from different startup position without either reconstructing server_state or adding setter method for initial position. As the only use for initial_position in server state was to pass it to provider during provider load, it makes more sense to have the initial position to be passed as an argument to server_state load_provider() method.
This commit is contained in:
@ -45,7 +45,6 @@ namespace db
|
||||
"",
|
||||
address,
|
||||
working_dir,
|
||||
wsrep::gtid::undefined(),
|
||||
1,
|
||||
wsrep::server_state::rm_async)
|
||||
, mutex_()
|
||||
|
@ -137,7 +137,8 @@ void db::simulator::start()
|
||||
std::string server_options(params_.wsrep_provider_options);
|
||||
|
||||
if (server.server_state().load_provider(
|
||||
params_.wsrep_provider, server_options))
|
||||
params_.wsrep_provider, server_options,
|
||||
wsrep::gtid::undefined()))
|
||||
{
|
||||
throw wsrep::runtime_error("Failed to load provider");
|
||||
}
|
||||
|
@ -362,7 +362,8 @@ namespace wsrep
|
||||
static provider* make_provider(
|
||||
wsrep::server_state&,
|
||||
const std::string& provider_spec,
|
||||
const std::string& provider_options);
|
||||
const std::string& provider_options,
|
||||
const wsrep::gtid& initial_position);
|
||||
protected:
|
||||
wsrep::server_state& server_state_;
|
||||
};
|
||||
|
@ -212,11 +212,6 @@ namespace wsrep
|
||||
*/
|
||||
const std::string& working_dir() const { return working_dir_; }
|
||||
|
||||
/**
|
||||
* Return initial position for server.
|
||||
*/
|
||||
const wsrep::gtid& initial_position() const
|
||||
{ return initial_position_; }
|
||||
/**
|
||||
* Return maximum protocol version.
|
||||
*/
|
||||
@ -261,7 +256,8 @@ namespace wsrep
|
||||
* @return Zero on success, non-zero on error.
|
||||
*/
|
||||
int load_provider(const std::string& provider,
|
||||
const std::string& provider_options);
|
||||
const std::string& provider_options,
|
||||
const wsrep::gtid& intial_position);
|
||||
|
||||
void unload_provider();
|
||||
|
||||
@ -557,7 +553,7 @@ namespace wsrep
|
||||
const std::string& incoming_address,
|
||||
const std::string& address,
|
||||
const std::string& working_dir,
|
||||
const wsrep::gtid& initial_position,
|
||||
// const wsrep::gtid& initial_position,
|
||||
int max_protocol_version,
|
||||
enum rollback_mode rollback_mode)
|
||||
: mutex_(mutex)
|
||||
@ -567,7 +563,7 @@ namespace wsrep
|
||||
, state_hist_()
|
||||
, state_waiters_(n_states_)
|
||||
, bootstrap_()
|
||||
, initial_position_(initial_position)
|
||||
// , initial_position_(initial_position)
|
||||
, init_initialized_()
|
||||
, init_synced_()
|
||||
, sst_gtid_()
|
||||
@ -628,7 +624,7 @@ namespace wsrep
|
||||
std::vector<enum state> state_hist_;
|
||||
mutable std::vector<int> state_waiters_;
|
||||
bool bootstrap_;
|
||||
const wsrep::gtid initial_position_;
|
||||
// const wsrep::gtid initial_position_;
|
||||
bool init_initialized_;
|
||||
bool init_synced_;
|
||||
wsrep::gtid sst_gtid_;
|
||||
|
@ -25,12 +25,13 @@
|
||||
wsrep::provider* wsrep::provider::make_provider(
|
||||
wsrep::server_state& server_state,
|
||||
const std::string& provider_spec,
|
||||
const std::string& provider_options)
|
||||
const std::string& provider_options,
|
||||
const wsrep::gtid& initial_position)
|
||||
{
|
||||
try
|
||||
{
|
||||
return new wsrep::wsrep_provider_v26(
|
||||
server_state, provider_options, provider_spec);
|
||||
server_state, provider_options, provider_spec, initial_position);
|
||||
}
|
||||
catch (const wsrep::runtime_error& e)
|
||||
{
|
||||
|
@ -332,14 +332,15 @@ static int apply_toi(wsrep::provider& provider,
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
int wsrep::server_state::load_provider(const std::string& provider_spec,
|
||||
const std::string& provider_options)
|
||||
const std::string& provider_options,
|
||||
const wsrep::gtid& initial_position)
|
||||
{
|
||||
wsrep::log_info() << "Loading provider "
|
||||
<< provider_spec
|
||||
<< "initial position: "
|
||||
<< initial_position_;
|
||||
<< initial_position;
|
||||
provider_ = wsrep::provider::make_provider(
|
||||
*this, provider_spec, provider_options);
|
||||
*this, provider_spec, provider_options, initial_position);
|
||||
return (provider_ ? 0 : 1);
|
||||
}
|
||||
|
||||
|
@ -546,15 +546,16 @@ namespace
|
||||
wsrep::wsrep_provider_v26::wsrep_provider_v26(
|
||||
wsrep::server_state& server_state,
|
||||
const std::string& provider_options,
|
||||
const std::string& provider_spec)
|
||||
const std::string& provider_spec,
|
||||
const wsrep::gtid& initial_position)
|
||||
: provider(server_state)
|
||||
, wsrep_()
|
||||
{
|
||||
wsrep_gtid_t state_id;
|
||||
std::memcpy(state_id.uuid.data,
|
||||
server_state.initial_position().id().data(),
|
||||
initial_position.id().data(),
|
||||
sizeof(state_id.uuid.data));
|
||||
state_id.seqno = server_state.initial_position().seqno().get();
|
||||
state_id.seqno = initial_position.seqno().get();
|
||||
struct wsrep_init_args init_args;
|
||||
memset(&init_args, 0, sizeof(init_args));
|
||||
init_args.app_ctx = &server_state;
|
||||
|
@ -31,7 +31,7 @@ namespace wsrep
|
||||
public:
|
||||
|
||||
wsrep_provider_v26(wsrep::server_state&, const std::string&,
|
||||
const std::string&);
|
||||
const std::string&, const wsrep::gtid&);
|
||||
~wsrep_provider_v26();
|
||||
enum wsrep::provider::status
|
||||
connect(const std::string&, const std::string&, const std::string&,
|
||||
|
@ -214,7 +214,6 @@ namespace wsrep
|
||||
wsrep::server_service& server_service)
|
||||
: wsrep::server_state(mutex_, cond_, server_service,
|
||||
name, "", "", "./",
|
||||
wsrep::gtid::undefined(),
|
||||
1,
|
||||
rollback_mode)
|
||||
, mutex_()
|
||||
|
Reference in New Issue
Block a user