1
0
mirror of https://github.com/codership/wsrep-lib.git synced 2025-07-28 20:02:00 +03:00

Defined log_state_change() interface in server_service.

The interface method can be used to notify the DBMS implementation
about state changes in well defined order. The call will be done
under server_state mutex protection.
This commit is contained in:
Teemu Ollakka
2018-07-05 12:45:22 +03:00
parent fcefe9f03b
commit d80a69fe90
8 changed files with 61 additions and 59 deletions

View File

@ -3,6 +3,7 @@
//
#include "wsrep/server_state.hpp"
#include "wsrep/server_service.hpp"
#include "wsrep/high_priority_service.hpp"
#include "wsrep/transaction.hpp"
#include "wsrep/view.hpp"
@ -15,34 +16,6 @@
namespace
{
std::string cluster_status_string(enum wsrep::server_state::state state)
{
switch (state)
{
case wsrep::server_state::s_joined:
case wsrep::server_state::s_synced:
return "Primary";
default:
return "non-Primary";
}
}
std::string cluster_size_string(enum wsrep::server_state::state state,
const wsrep::view& current_view)
{
std::ostringstream oss;
oss << current_view.members().size();
return oss.str();
}
std::string local_index_string(enum wsrep::server_state::state state,
const wsrep::view& current_view)
{
std::ostringstream oss;
oss << current_view.own_index();
return oss.str();
}
//
// This method is used to deal with historical burden of several
// ways to bootstrap the cluster. Bootstrap happens if
@ -255,15 +228,7 @@ wsrep::server_state::~server_state()
std::vector<wsrep::provider::status_variable>
wsrep::server_state::status() const
{
typedef wsrep::provider::status_variable sv;
std::vector<sv> ret(provider_->status());
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
ret.push_back(sv("cluster_status", cluster_status_string(state_)));
ret.push_back(sv("cluster_size",
cluster_size_string(state_, current_view_)));
ret.push_back(sv("local_index",
local_index_string(state_, current_view_)));
return ret;
return provider_->status();
}
@ -493,6 +458,7 @@ void wsrep::server_state::on_view(const wsrep::view& view)
<< "name: " << i->name();
}
wsrep::log_info() << "=================================================";
server_service_.log_view(view);
current_view_ = view;
if (view.status() == wsrep::view::primary)
{
@ -590,7 +556,6 @@ void wsrep::server_state::on_view(const wsrep::view& view)
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
state(lock, s_disconnected);
}
server_service_.log_view(view);
}
void wsrep::server_state::on_sync()
@ -754,10 +719,11 @@ void wsrep::server_state::state(
if (allowed[state_][state])
{
wsrep::log_info() << "server " << name_ << " state change: "
<< to_c_string(state_) << " -> "
<< to_c_string(state);
wsrep::log_debug() << "server " << name_ << " state change: "
<< to_c_string(state_) << " -> "
<< to_c_string(state);
state_hist_.push_back(state_);
server_service_.log_state_change(state_, state);
state_ = state;
cond_.notify_all();
while (state_waiters_[state_])

View File

@ -841,7 +841,12 @@ int wsrep::transaction::certify_commit(
if (client_service_.prepare_data_for_replication())
{
lock.lock();
client_state_.override_error(wsrep::e_size_exceeded_error);
// Here we fake that the size exceeded error came from provider,
// even though it came from the client service. This requires
// some consideration how to get meaningful error codes from
// the client service.
client_state_.override_error(wsrep::e_size_exceeded_error,
wsrep::provider::error_size_exceeded);
if (state_ != s_must_abort)
{
state(lock, s_must_abort);