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(
|
||||
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::condition_variable& cond_;
|
||||
wsrep::server_service& server_service_;
|
||||
|
@ -674,13 +674,7 @@ int wsrep::server_state::start_sst(const std::string& sst_request,
|
||||
{
|
||||
lock.lock();
|
||||
wsrep::log_warning() << "SST preparation failed";
|
||||
// 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);
|
||||
}
|
||||
return_from_donor_state(lock);
|
||||
ret = 1;
|
||||
}
|
||||
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::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
|
||||
// donor state e.g. due to cluster partitioning.
|
||||
if (state(lock) == s_donor)
|
||||
{
|
||||
state(lock, s_joined);
|
||||
}
|
||||
|
||||
return_from_donor_state(lock);
|
||||
|
||||
lock.unlock();
|
||||
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_);
|
||||
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,15 +173,14 @@ namespace wsrep
|
||||
{ return sst_before_init_; }
|
||||
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&,
|
||||
bool) WSREP_OVERRIDE
|
||||
{
|
||||
if (start_sst_action)
|
||||
{
|
||||
return start_sst_action();
|
||||
}
|
||||
return 0;
|
||||
return start_sst_action();
|
||||
}
|
||||
|
||||
void
|
||||
|
Loading…
x
Reference in New Issue
Block a user