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

codership/wsrep-lib#54 Fixed race in server disconnect

Convert streaming client to applier only if the server is not
in disconnected state. In disconnected state the appliers map
is supposed to be empty and will be reconstructed from fragment
storage when the server is connected back to cluster.
This commit is contained in:
Teemu Ollakka
2019-01-18 14:52:54 +02:00
parent a6b38d2428
commit 6e2c70c226

View File

@ -957,21 +957,29 @@ void wsrep::server_state::convert_streaming_client_to_applier(
{
streaming_clients_.erase(i);
}
wsrep::high_priority_service* streaming_applier(
server_service_.streaming_applier_service(
client_state->client_service()));
streaming_applier->adopt_transaction(client_state->transaction());
if (streaming_appliers_.insert(
std::make_pair(
std::make_pair(client_state->transaction().server_id(),
client_state->transaction().id()),
streaming_applier)).second == false)
// Convert to applier only if the state is not disconnected. In
// disconnected state the applier map is supposed to be empty
// and it will be reconstructed from fragment storage when
// joining back to cluster.
if (state(lock) != s_disconnected)
{
wsrep::log_warning() << "Could not insert streaming applier "
<< id_
<< ", "
<< client_state->transaction().id();
assert(0);
wsrep::high_priority_service* streaming_applier(
server_service_.streaming_applier_service(
client_state->client_service()));
streaming_applier->adopt_transaction(client_state->transaction());
if (streaming_appliers_.insert(
std::make_pair(
std::make_pair(client_state->transaction().server_id(),
client_state->transaction().id()),
streaming_applier)).second == false)
{
wsrep::log_warning() << "Could not insert streaming applier "
<< id_
<< ", "
<< client_state->transaction().id();
assert(0);
}
}
}