mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-04-19 21:02:17 +03:00
Extracted duplicate logic into return_from_donor_state
The condition to skip changing to `s_joined` for all codepaths which return from donor state. Extracted the logic into separate method. Commented start_sst_action in mock_server_service.
This commit is contained in:
parent
5a943b66a7
commit
7843345a19
@ -674,6 +674,9 @@ namespace wsrep
|
|||||||
enum wsrep::provider::status send_pending_rollback_events(
|
enum wsrep::provider::status send_pending_rollback_events(
|
||||||
wsrep::unique_lock<wsrep::mutex>& lock);
|
wsrep::unique_lock<wsrep::mutex>& lock);
|
||||||
|
|
||||||
|
// Handle returning from donor state.
|
||||||
|
void return_from_donor_state(wsrep::unique_lock<wsrep::mutex>& lock);
|
||||||
|
|
||||||
wsrep::mutex& mutex_;
|
wsrep::mutex& mutex_;
|
||||||
wsrep::condition_variable& cond_;
|
wsrep::condition_variable& cond_;
|
||||||
wsrep::server_service& server_service_;
|
wsrep::server_service& server_service_;
|
||||||
|
@ -674,13 +674,7 @@ int wsrep::server_state::start_sst(const std::string& sst_request,
|
|||||||
{
|
{
|
||||||
lock.lock();
|
lock.lock();
|
||||||
wsrep::log_warning() << "SST preparation failed";
|
wsrep::log_warning() << "SST preparation failed";
|
||||||
// v26 API does not have JOINED event, so in anticipation of SYNCED
|
return_from_donor_state(lock);
|
||||||
// we must do it here. Do not modify the state if donor lost the
|
|
||||||
// donor state e.g. due to cluster partitioning.
|
|
||||||
if (state(lock) == s_donor)
|
|
||||||
{
|
|
||||||
state(lock, s_joined);
|
|
||||||
}
|
|
||||||
ret = 1;
|
ret = 1;
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
@ -694,13 +688,8 @@ void wsrep::server_state::sst_sent(const wsrep::gtid& gtid, int error)
|
|||||||
wsrep::log_info() << "SST sending failed: " << error;
|
wsrep::log_info() << "SST sending failed: " << error;
|
||||||
|
|
||||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
// v26 API does not have JOINED event, so in anticipation of SYNCED
|
|
||||||
// we must do it here. Do not modify the state if donor lost the
|
return_from_donor_state(lock);
|
||||||
// donor state e.g. due to cluster partitioning.
|
|
||||||
if (state(lock) == s_donor)
|
|
||||||
{
|
|
||||||
state(lock, s_joined);
|
|
||||||
}
|
|
||||||
|
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
enum provider::status const retval(provider().sst_sent(gtid, error));
|
enum provider::status const retval(provider().sst_sent(gtid, error));
|
||||||
@ -1650,3 +1639,16 @@ wsrep::server_state::send_pending_rollback_events()
|
|||||||
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
|
||||||
return send_pending_rollback_events(lock);
|
return send_pending_rollback_events(lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wsrep::server_state::return_from_donor_state(
|
||||||
|
wsrep::unique_lock<wsrep::mutex>& lock)
|
||||||
|
{
|
||||||
|
assert(lock.owns_lock());
|
||||||
|
// v26 API does not have JOINED event, so in anticipation of SYNCED
|
||||||
|
// we must do it here. Do not modify the state if donor lost the
|
||||||
|
// donor state e.g. due to cluster partitioning.
|
||||||
|
if (state(lock) == s_donor)
|
||||||
|
{
|
||||||
|
state(lock, s_joined);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -173,16 +173,15 @@ namespace wsrep
|
|||||||
{ return sst_before_init_; }
|
{ return sst_before_init_; }
|
||||||
std::string sst_request() WSREP_OVERRIDE { return ""; }
|
std::string sst_request() WSREP_OVERRIDE { return ""; }
|
||||||
|
|
||||||
std::function<int()> start_sst_action{};
|
// Action to take when start_sst() method is called.
|
||||||
|
// This can be overriden by test case to inject custom
|
||||||
|
// behavior.
|
||||||
|
std::function<int()> start_sst_action{[](){ return 0; }};
|
||||||
int start_sst(const std::string&, const wsrep::gtid&,
|
int start_sst(const std::string&, const wsrep::gtid&,
|
||||||
bool) WSREP_OVERRIDE
|
bool) WSREP_OVERRIDE
|
||||||
{
|
|
||||||
if (start_sst_action)
|
|
||||||
{
|
{
|
||||||
return start_sst_action();
|
return start_sst_action();
|
||||||
}
|
}
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
background_rollback(wsrep::client_state& client_state) WSREP_OVERRIDE
|
background_rollback(wsrep::client_state& client_state) WSREP_OVERRIDE
|
||||||
|
Loading…
x
Reference in New Issue
Block a user