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

Tests and fixes for replaying.

This commit is contained in:
Teemu Ollakka
2018-06-14 15:00:40 +03:00
parent ca6286d8b2
commit 0b6e49474f
11 changed files with 123 additions and 21 deletions

View File

@ -137,7 +137,7 @@ int wsrep::server_context::on_apply(
}
else
{
client_context.start_replaying();
client_context.start_replaying(ws_meta);
}
if (client_context.apply(data))
@ -251,7 +251,7 @@ int wsrep::server_context::on_apply(
}
else
{
ret = client_context.start_replaying() ||
ret = client_context.start_replaying(ws_meta) ||
client_context.apply(wsrep::const_buffer()) ||
client_context.commit();
}

View File

@ -80,8 +80,9 @@ int wsrep::transaction_context::start_transaction(
return 0;
}
int wsrep::transaction_context::start_replaying()
int wsrep::transaction_context::start_replaying(const wsrep::ws_meta& ws_meta)
{
ws_meta_ = ws_meta;
assert(ws_meta_.flags() & wsrep::provider::flag::commit);
assert(active());
assert(client_context_.mode() == wsrep::client_context::m_applier);
@ -506,12 +507,32 @@ int wsrep::transaction_context::after_statement()
// Continue to replay if rollback() changed the state to s_must_replay
// Fall through
case s_must_replay:
{
state(lock, s_replaying);
lock.unlock();
ret = client_context_.replay(*this);
enum wsrep::provider::status replay_ret(client_context_.replay(*this));
switch (replay_ret)
{
case wsrep::provider::success:
break;
case wsrep::provider::error_certification_failed:
client_context_.override_error(
wsrep::e_deadlock_error);
ret = 1;
break;
default:
client_context_.abort();
break;
}
lock.lock();
if (ret)
{
wsrep::log_info() << "Replay ret " << replay_ret;
state(lock, s_aborted);
}
provider_.release(ws_handle_);
break;
}
case s_aborted:
break;
default:
@ -650,7 +671,7 @@ void wsrep::transaction_context::state(
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0}, /* ab */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}, /* ad */
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1}, /* mr */
{ 0, 1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0} /* re */
{ 0, 1, 0, 1, 0, 0, 0, 0, 0, 1, 0, 0} /* re */
};
if (allowed[state_][next_state])
{
@ -852,7 +873,6 @@ int wsrep::transaction_context::certify_commit(
// yet known. Therefore the transaction must roll back
// and go through replay either to replay and commit the whole
// transaction or to determine failed certification status.
assert(ordered());
client_context_.will_replay(*this);
if (state() != s_must_abort)
{

View File

@ -548,11 +548,13 @@ int wsrep::wsrep_provider_v26::release(wsrep::ws_handle& ws_handle)
return (wsrep_->release(wsrep_, mwsh.native()) != WSREP_OK);
}
int wsrep::wsrep_provider_v26::replay(wsrep::ws_handle& ws_handle,
void* applier_ctx)
enum wsrep::provider::status
wsrep::wsrep_provider_v26::replay(wsrep::ws_handle& ws_handle,
void* applier_ctx)
{
mutable_ws_handle mwsh(ws_handle);
return (wsrep_->replay_trx(wsrep_, mwsh.native(), applier_ctx) != WSREP_OK);
return map_return_value(
wsrep_->replay_trx(wsrep_, mwsh.native(), applier_ctx));
}
int wsrep::wsrep_provider_v26::sst_sent(const wsrep::gtid& gtid, int err)

View File

@ -41,7 +41,7 @@ namespace wsrep
int commit_order_leave(const wsrep::ws_handle&,
const wsrep::ws_meta&);
int release(wsrep::ws_handle&);
int replay(wsrep::ws_handle&, void*);
enum wsrep::provider::status replay(wsrep::ws_handle&, void*);
int sst_sent(const wsrep::gtid&,int);
int sst_received(const wsrep::gtid& gtid, int);