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

codership/wsrep-lib#13 Fix dbsim to deal with provider generated server id

Dbsim has internal map of server objects for SST simulation.
This was mapped using server_id, which is not available
anymore when server object is constructed. Changed the dbsim to
use server name instead for internal mapping.
This commit is contained in:
Teemu Ollakka
2018-11-06 18:14:37 +02:00
committed by Alexey Yurchenko
parent ea9971d54b
commit c7e8bfbdb5
4 changed files with 21 additions and 11 deletions

View File

@ -86,7 +86,7 @@ int db::high_priority_service::rollback(const wsrep::ws_handle& ws_handle,
void db::high_priority_service::after_apply()
{
client_.client_state_.after_statement();
client_.client_state_.after_applying();
}
bool db::high_priority_service::is_replaying() const

View File

@ -72,9 +72,9 @@ bool db::server_service::sst_before_init() const
std::string db::server_service::sst_request()
{
std::ostringstream os;
os << server_.server_state().id();
os << server_.server_state().name();
wsrep::log_info() << "SST request: "
<< server_.server_state().id();
<< server_.server_state().name();
return os.str();
}

View File

@ -38,19 +38,29 @@ void db::simulator::sst(db::server& server,
const wsrep::gtid& gtid,
bool bypass)
{
wsrep::id id;
std::istringstream is(request);
is >> id;
// The request may contain extra trailing '\0' after it goes
// through the provider, strip it first.
std::string name(request);
name.erase(std::find(name.begin(), name.end(), '\0'), name.end());
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
auto i(servers_.find(id));
wsrep::log_info() << "SST request";
auto i(servers_.find(name));
wsrep::log_info() << "SST request '" << name << "'";
if (i == servers_.end())
{
wsrep::log_error() << "Server " << request << " not found";
wsrep::log_info() << "servers:";
for (const auto& s : servers_)
{
wsrep::log_info() << "server: " << s.first;
}
throw wsrep::runtime_error("Server " + request + " not found");
}
if (bypass == false)
{
wsrep::log_info() << "SST " << server.server_state().id() << " -> " << id;
wsrep::log_info() << "SST "
<< server.server_state().name()
<< " -> " << request;
}
i->second->server_state().sst_received(gtid, 0);
server.server_state().sst_sent(gtid, 0);
@ -105,7 +115,7 @@ void db::simulator::start()
wsrep::id server_id(id_os.str());
auto it(servers_.insert(
std::make_pair(
server_id,
name_os.str(),
std::make_unique<db::server>(
*this,
name_os.str(),

View File

@ -61,7 +61,7 @@ namespace db
wsrep::default_mutex mutex_;
const db::params& params_;
std::map<wsrep::id, std::unique_ptr<db::server>> servers_;
std::map<std::string, std::unique_ptr<db::server>> servers_;
std::chrono::time_point<std::chrono::steady_clock> clients_start_;
std::chrono::time_point<std::chrono::steady_clock> clients_stop_;
public: