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

error parameter to nbo calls and m_undefined for toi_mode

toi_mode is set only when actually inside phase one and two.
In between it goes back to m_undefined.
This commit is contained in:
Leandro Pacheco
2019-08-28 18:36:17 -03:00
committed by Teemu Ollakka
parent 0b12869715
commit 5298d2340e
10 changed files with 60 additions and 41 deletions

View File

@ -98,7 +98,8 @@ int wsrep::mock_high_priority_service::apply_toi(const wsrep::ws_meta&,
int wsrep::mock_high_priority_service::apply_nbo_begin(
const wsrep::ws_meta& ws_meta,
const wsrep::const_buffer&)
const wsrep::const_buffer&,
wsrep::mutable_buffer&)
{
const int nbo_begin_flags(wsrep::provider::flag::isolation |
wsrep::provider::flag::start_transaction);

View File

@ -71,7 +71,8 @@ namespace wsrep
const wsrep::const_buffer&,
wsrep::mutable_buffer&) WSREP_OVERRIDE;
int apply_nbo_begin(const wsrep::ws_meta&,
const wsrep::const_buffer&) WSREP_OVERRIDE;
const wsrep::const_buffer&,
wsrep::mutable_buffer&) WSREP_OVERRIDE;
void adopt_apply_error(wsrep::mutable_buffer& err) WSREP_OVERRIDE;
void after_apply() WSREP_OVERRIDE;
void store_globals() WSREP_OVERRIDE { }

View File

@ -43,10 +43,11 @@ BOOST_FIXTURE_TEST_CASE(test_local_nbo,
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
// After required resoureces have been grabbed, NBO leave should
// end TOI but leave the client state in m_nbo.
BOOST_REQUIRE(cc.end_nbo_phase_one() == 0);
const wsrep::mutable_buffer err;
BOOST_REQUIRE(cc.end_nbo_phase_one(err) == 0);
BOOST_REQUIRE(cc.mode() == wsrep::client_state::m_nbo);
BOOST_REQUIRE(cc.in_toi() == false);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
// Second phase replicates the NBO end event and grabs TOI
// again for finalizing the NBO.
BOOST_REQUIRE(cc.begin_nbo_phase_two() == 0);
@ -55,10 +56,10 @@ BOOST_FIXTURE_TEST_CASE(test_local_nbo,
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
// End of NBO phase will leave TOI and put the client state back to
// m_local
BOOST_REQUIRE(cc.end_nbo_phase_two() == 0);
BOOST_REQUIRE(cc.end_nbo_phase_two(err) == 0);
BOOST_REQUIRE(cc.mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.in_toi() == false);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
// There must have been two toi write sets, one with
// start transaction flag, another with commit flag.
@ -88,7 +89,7 @@ BOOST_FIXTURE_TEST_CASE(test_local_nbo_cert_failure,
wsrep::provider::error_certification_failed);
BOOST_REQUIRE(cc.mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.in_toi() == false);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
}
// This test case operates through server_state object in order to
@ -115,7 +116,8 @@ BOOST_FIXTURE_TEST_CASE(test_applying_nbo,
nbo_begin.size())) == 0);
wsrep::mock_client* nbo_cs(hps.nbo_cs());
BOOST_REQUIRE(nbo_cs);
BOOST_REQUIRE(nbo_cs->toi_mode() == wsrep::client_state::m_local);
// TODO(leandro): should applying side really be m_local here?
BOOST_REQUIRE(nbo_cs->toi_mode() == wsrep::client_state::m_undefined);
BOOST_REQUIRE(nbo_cs->mode() == wsrep::client_state::m_nbo);
// After this point the control is on local process and applier
@ -131,10 +133,11 @@ BOOST_FIXTURE_TEST_CASE(test_applying_nbo,
BOOST_REQUIRE(nbo_cs->toi_mode() == wsrep::client_state::m_local);
// Ending phase two should make nbo_cs leave TOI mode and
// return to m_local mode.
BOOST_REQUIRE(nbo_cs->end_nbo_phase_two() == 0);
const wsrep::mutable_buffer err;
BOOST_REQUIRE(nbo_cs->end_nbo_phase_two(err) == 0);
BOOST_REQUIRE(nbo_cs->mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(nbo_cs->in_toi() == false);
BOOST_REQUIRE(nbo_cs->toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(nbo_cs->toi_mode() == wsrep::client_state::m_undefined);
// There must have been one toi write set with commit flag.
BOOST_REQUIRE(sc.provider().toi_write_sets() == 1);

View File

@ -27,21 +27,22 @@ BOOST_FIXTURE_TEST_CASE(test_toi_mode,
replicating_client_fixture_sync_rm)
{
BOOST_REQUIRE(cc.mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
wsrep::key key(wsrep::key::exclusive);
key.append_key_part("k1", 2);
key.append_key_part("k2", 2);
wsrep::key_array keys{key};
wsrep::const_buffer buf("toi", 3);
BOOST_REQUIRE(cc.enter_toi(keys, buf,
wsrep::provider::flag::start_transaction |
wsrep::provider::flag::commit) == 0);
BOOST_REQUIRE(cc.enter_toi_local(keys, buf,
wsrep::provider::flag::start_transaction |
wsrep::provider::flag::commit) == 0);
BOOST_REQUIRE(cc.mode() == wsrep::client_state::m_toi);
BOOST_REQUIRE(cc.in_toi());
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.leave_toi() == 0);
wsrep::mutable_buffer err;
BOOST_REQUIRE(cc.leave_toi_local(err) == 0);
BOOST_REQUIRE(cc.mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
BOOST_REQUIRE(sc.provider().toi_write_sets() == 1);
BOOST_REQUIRE(sc.provider().toi_start_transaction() == 1);
BOOST_REQUIRE(sc.provider().toi_commit() == 1);
@ -50,7 +51,7 @@ BOOST_FIXTURE_TEST_CASE(test_toi_mode,
BOOST_FIXTURE_TEST_CASE(test_toi_applying,
applying_client_fixture)
{
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(2)),
wsrep::stid(sc.id(),
wsrep::transaction_id::undefined(),
@ -58,10 +59,10 @@ BOOST_FIXTURE_TEST_CASE(test_toi_applying,
wsrep::seqno(1),
wsrep::provider::flag::start_transaction |
wsrep::provider::flag::commit);
BOOST_REQUIRE(cc.enter_toi(ws_meta) == 0);
cc.enter_toi_mode(ws_meta);
BOOST_REQUIRE(cc.in_toi());
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_high_priority);
BOOST_REQUIRE(cc.leave_toi() == 0);
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_local);
cc.leave_toi_mode();
BOOST_REQUIRE(cc.toi_mode() == wsrep::client_state::m_undefined);
cc.after_applying();
}