From ddc6c6495b0e3c368c1e374b944d106deaf76b8e Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Wed, 11 Jul 2018 15:00:31 +0300 Subject: [PATCH] Made client_id, transaction_id constructors explicit. --- dbsim/db_client.cpp | 2 +- dbsim/db_server.cpp | 2 +- dbsim/db_server.hpp | 2 +- include/wsrep/client_id.hpp | 2 +- include/wsrep/client_state.hpp | 2 +- include/wsrep/transaction_id.hpp | 6 +-- src/transaction.cpp | 18 ++++---- src/wsrep_provider_v26.cpp | 15 +++--- test/client_state_fixture.hpp | 12 +++-- test/mock_server_state.hpp | 12 +++-- test/server_context_test.cpp | 19 +++++--- test/transaction_test.cpp | 78 ++++++++++++++++---------------- test/transaction_test_2pc.cpp | 16 +++---- 13 files changed, 102 insertions(+), 84 deletions(-) diff --git a/dbsim/db_client.cpp b/dbsim/db_client.cpp index c0ab683..0b67991 100644 --- a/dbsim/db_client.cpp +++ b/dbsim/db_client.cpp @@ -79,7 +79,7 @@ void db::client::run_one_transaction() { // wsrep::log_debug() << "Start transaction"; err = client_state_.start_transaction( - server_.next_transaction_id()); + wsrep::transaction_id(server_.next_transaction_id())); assert(err == 0); se_trx_.start(this); return err; diff --git a/dbsim/db_server.cpp b/dbsim/db_server.cpp index 1bc212f..c13acc6 100644 --- a/dbsim/db_server.cpp +++ b/dbsim/db_server.cpp @@ -95,7 +95,7 @@ void db::server::client_thread(const std::shared_ptr& client) void db::server::start_client(size_t id) { auto client(std::make_shared( - *this, id, + *this, wsrep::client_id(id), wsrep::client_state::m_local, simulator_.params())); clients_.push_back(client); diff --git a/dbsim/db_server.hpp b/dbsim/db_server.hpp index 24e10bc..2b78cf3 100644 --- a/dbsim/db_server.hpp +++ b/dbsim/db_server.hpp @@ -38,7 +38,7 @@ namespace db db::server_state& server_state() { return server_state_; } wsrep::transaction_id next_transaction_id() { - return (last_transaction_id_.fetch_add(1) + 1); + return wsrep::transaction_id(last_transaction_id_.fetch_add(1) + 1); } void donate_sst(const std::string&, const wsrep::gtid&, bool); wsrep::client_state* local_client_state(); diff --git a/include/wsrep/client_id.hpp b/include/wsrep/client_id.hpp index 5d71d15..df43791 100644 --- a/include/wsrep/client_id.hpp +++ b/include/wsrep/client_id.hpp @@ -15,7 +15,7 @@ namespace wsrep : id_(-1) { } template - client_id(I id) + explicit client_id(I id) : id_(static_cast(id)) { } type get() const { return id_; } diff --git a/include/wsrep/client_state.hpp b/include/wsrep/client_state.hpp index fccb5ea..7b1e29c 100644 --- a/include/wsrep/client_state.hpp +++ b/include/wsrep/client_state.hpp @@ -421,7 +421,7 @@ namespace wsrep int bf_abort(wsrep::seqno bf_seqno) { wsrep::unique_lock lock(mutex_); - assert(mode_ == m_local); + assert(mode_ == m_local || transaction_.is_streaming()); return transaction_.bf_abort(lock, bf_seqno); } diff --git a/include/wsrep/transaction_id.hpp b/include/wsrep/transaction_id.hpp index f373283..5cabea3 100644 --- a/include/wsrep/transaction_id.hpp +++ b/include/wsrep/transaction_id.hpp @@ -5,7 +5,7 @@ #ifndef WSREP_TRANSACTION_ID_HPP #define WSREP_TRANSACTION_ID_HPP -#include +#include namespace wsrep { @@ -20,11 +20,11 @@ namespace wsrep { } template - transaction_id(I id) + explicit transaction_id(I id) : id_(static_cast(id)) { } type get() const { return id_; } - static unsigned long long undefined() { return type(-1); } + static transaction_id undefined() { return transaction_id(-1); } bool is_undefined() const { return (id_ == type(-1)); } bool operator<(const transaction_id& other) const { diff --git a/src/transaction.cpp b/src/transaction.cpp index 6d33407..5c2af81 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -554,7 +554,7 @@ int wsrep::transaction::before_rollback() case s_aborting: if (is_streaming()) { - provider().rollback(id_.get()); + provider().rollback(id_); } break; case s_must_replay: @@ -782,12 +782,12 @@ bool wsrep::transaction::bf_abort( wsrep::seqno victim_seqno; enum wsrep::provider::status status(client_state_.provider().bf_abort( - bf_seqno, id_.get(), victim_seqno)); + bf_seqno, id_, victim_seqno)); switch (status) { case wsrep::provider::success: WSREP_TC_LOG_DEBUG(1, "Seqno " << bf_seqno - << " succesfully BF aborted " << id_.get() + << " succesfully BF aborted " << id_ << " victim_seqno " << victim_seqno); bf_abort_state_ = state(); state(lock, s_must_abort); @@ -796,7 +796,7 @@ bool wsrep::transaction::bf_abort( default: WSREP_TC_LOG_DEBUG(1, "Seqno " << bf_seqno - << " failed to BF abort " << id_.get() + << " failed to BF abort " << id_ << " with status " << status << " victim_seqno " << victim_seqno); break; @@ -882,7 +882,7 @@ void wsrep::transaction::state( { std::ostringstream os; os << "unallowed state transition for transaction " - << id_.get() << ": " << wsrep::to_string(state_) + << id_ << ": " << wsrep::to_string(state_) << " -> " << wsrep::to_string(next_state); wsrep::log_error() << os.str(); throw wsrep::runtime_error(os.str()); @@ -963,7 +963,7 @@ int wsrep::transaction::certify_fragment( wsrep::ws_meta sr_ws_meta; enum wsrep::provider::status - cert_ret(provider().certify(client_state_.id().get(), + cert_ret(provider().certify(client_state_.id(), ws_handle_, flags(), sr_ws_meta)); @@ -1062,7 +1062,7 @@ int wsrep::transaction::certify_commit( client_service_.debug_sync("wsrep_before_certification"); enum wsrep::provider::status - cert_ret(provider().certify(client_state_.id().get(), + cert_ret(provider().certify(client_state_.id(), ws_handle_, flags(), ws_meta_)); @@ -1213,10 +1213,10 @@ void wsrep::transaction::streaming_rollback() streaming_context_.cleanup(); streaming_context_.rolled_back(id_); enum wsrep::provider::status ret; - if ((ret = provider().rollback(id_.get()))) + if ((ret = provider().rollback(id_))) { wsrep::log_warning() << "Failed to replicate rollback fragment for " - << id_.get() << ": " << ret; + << id_ << ": " << ret; } debug_log_state("streaming_rollback leave"); } diff --git a/src/wsrep_provider_v26.cpp b/src/wsrep_provider_v26.cpp index 6963606..4b21859 100644 --- a/src/wsrep_provider_v26.cpp +++ b/src/wsrep_provider_v26.cpp @@ -135,7 +135,8 @@ namespace ~mutable_ws_handle() { - ws_handle_ = wsrep::ws_handle(native_.trx_id, native_.opaque); + ws_handle_ = wsrep::ws_handle( + wsrep::transaction_id(native_.trx_id), native_.opaque); } wsrep_ws_handle_t* native() @@ -192,8 +193,8 @@ namespace seqno_from_native(trx_meta_.gtid.seqno)), wsrep::stid(wsrep::id(trx_meta_.stid.node.data, sizeof(trx_meta_.stid.node.data)), - trx_meta_.stid.trx, - trx_meta_.stid.conn), + wsrep::transaction_id(trx_meta_.stid.trx), + wsrep::client_id(trx_meta_.stid.conn)), seqno_from_native(trx_meta_.depends_on), flags_); } @@ -368,15 +369,17 @@ namespace assert(high_priority_service); wsrep::const_buffer data(buf->ptr, buf->len); - wsrep::ws_handle ws_handle(wsh->trx_id, wsh->opaque); + wsrep::ws_handle ws_handle(wsrep::transaction_id(wsh->trx_id), + wsh->opaque); wsrep::ws_meta ws_meta( wsrep::gtid(wsrep::id(meta->gtid.uuid.data, sizeof(meta->gtid.uuid.data)), wsrep::seqno(meta->gtid.seqno)), wsrep::stid(wsrep::id(meta->stid.node.data, sizeof(meta->stid.node.data)), - meta->stid.trx, - meta->stid.conn), wsrep::seqno(seqno_from_native(meta->depends_on)), + wsrep::transaction_id(meta->stid.trx), + wsrep::client_id(meta->stid.conn)), + wsrep::seqno(seqno_from_native(meta->depends_on)), map_flags_from_native(flags)); try { diff --git a/test/client_state_fixture.hpp b/test/client_state_fixture.hpp index 95c65f2..5a73201 100644 --- a/test/client_state_fixture.hpp +++ b/test/client_state_fixture.hpp @@ -108,9 +108,11 @@ namespace cc.open(cc.id()); BOOST_REQUIRE(cc.before_command() == 0); BOOST_REQUIRE(cc.before_statement() == 0); - wsrep::ws_handle ws_handle(1, (void*)1); + wsrep::ws_handle ws_handle(wsrep::transaction_id(1), (void*)1); wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)), - wsrep::stid(sc.id(), 1, cc.id()), + wsrep::stid(sc.id(), + wsrep::transaction_id(1), + cc.id()), wsrep::seqno(0), wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit); @@ -138,9 +140,11 @@ namespace cc.do_2pc_ = true; BOOST_REQUIRE(cc.before_command() == 0); BOOST_REQUIRE(cc.before_statement() == 0); - wsrep::ws_handle ws_handle(1, (void*)1); + wsrep::ws_handle ws_handle(wsrep::transaction_id(1), (void*)1); wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)), - wsrep::stid(sc.id(), 1, cc.id()), + wsrep::stid(sc.id(), + wsrep::transaction_id(1), + cc.id()), wsrep::seqno(0), wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit); diff --git a/test/mock_server_state.hpp b/test/mock_server_state.hpp index 77f1f3c..5840b10 100644 --- a/test/mock_server_state.hpp +++ b/test/mock_server_state.hpp @@ -41,7 +41,8 @@ namespace wsrep wsrep::storage_service* storage_service(wsrep::client_service&) { - return new wsrep::mock_storage_service(*this, ++last_client_id_); + return new wsrep::mock_storage_service(*this, + wsrep::client_id(++last_client_id_)); } void release_storage_service(wsrep::storage_service* storage_service) @@ -52,7 +53,8 @@ namespace wsrep wsrep::client_state* local_client_state() { wsrep::client_state* ret(new wsrep::mock_client( - *this, ++last_client_id_, + *this, + wsrep::client_id(++last_client_id_), wsrep::client_state::m_local)); ret->open(ret->id()); return ret; @@ -67,7 +69,8 @@ namespace wsrep wsrep::client_service&) { wsrep::mock_client* cs(new wsrep::mock_client( - *this, ++last_client_id_, + *this, + wsrep::client_id(++last_client_id_), wsrep::client_state::m_high_priority)); wsrep::mock_high_priority_service* ret( new wsrep::mock_high_priority_service(*this, cs, false)); @@ -80,7 +83,8 @@ namespace wsrep wsrep::high_priority_service&) { wsrep::mock_client* cs(new wsrep::mock_client( - *this, ++last_client_id_, + *this, + wsrep::client_id(++last_client_id_), wsrep::client_state::m_high_priority)); wsrep::mock_high_priority_service* ret( new wsrep::mock_high_priority_service(*this, cs, false)); diff --git a/test/server_context_test.cpp b/test/server_context_test.cpp index fb959e3..3dcd878 100644 --- a/test/server_context_test.cpp +++ b/test/server_context_test.cpp @@ -17,9 +17,10 @@ namespace wsrep::client_id(1), wsrep::client_state::m_high_priority) , hps(ss, &cc, false) - , ws_handle(1, (void*)1) + , ws_handle(wsrep::transaction_id(1), (void*)1) , ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)), - wsrep::stid(wsrep::id("1"), 1, 1), + wsrep::stid(wsrep::id("1"), wsrep::transaction_id(1), + wsrep::client_id(1)), wsrep::seqno(0), wsrep::provider::flag::start_transaction | wsrep::provider::flag::commit) @@ -114,9 +115,11 @@ BOOST_AUTO_TEST_CASE(server_state_streaming) wsrep::client_state::m_high_priority); cc.debug_log_level(1); wsrep::mock_high_priority_service hps(ss, &cc, false); - wsrep::ws_handle ws_handle(1, (void*)1); + wsrep::ws_handle ws_handle(wsrep::transaction_id(1), (void*)1); wsrep::ws_meta ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(1)), - wsrep::stid(wsrep::id("1"), 1, 1), + wsrep::stid(wsrep::id("1"), + wsrep::transaction_id(1), + wsrep::client_id(1)), wsrep::seqno(0), wsrep::provider::flag::start_transaction); cc.open(cc.id()); @@ -126,13 +129,17 @@ BOOST_AUTO_TEST_CASE(server_state_streaming) BOOST_REQUIRE(ss.find_streaming_applier( ws_meta.server_id(), ws_meta.transaction_id())); ws_meta = wsrep::ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(2)), - wsrep::stid(wsrep::id("1"), 1, 1), + wsrep::stid(wsrep::id("1"), + wsrep::transaction_id(1), + wsrep::client_id(1)), wsrep::seqno(1), 0); BOOST_REQUIRE(ss.on_apply(hps, ws_handle, ws_meta, wsrep::const_buffer("1", 1)) == 0); ws_meta = wsrep::ws_meta(wsrep::gtid(wsrep::id("1"), wsrep::seqno(2)), - wsrep::stid(wsrep::id("1"), 1, 1), + wsrep::stid(wsrep::id("1"), + wsrep::transaction_id(1), + wsrep::client_id(1)), wsrep::seqno(1), wsrep::provider::flag::commit); BOOST_REQUIRE(ss.on_apply(hps, ws_handle, ws_meta, diff --git a/test/transaction_test.cpp b/test/transaction_test.cpp index 19fcb22..9f939c8 100644 --- a/test/transaction_test.cpp +++ b/test/transaction_test.cpp @@ -21,7 +21,7 @@ namespace BOOST_FIXTURE_TEST_CASE(transaction_append_key_data, replicating_client_fixture_sync_rm) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); int vals[3] = {1, 2, 3}; wsrep::key key(wsrep::key::exclusive); @@ -46,7 +46,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_1pc, T, wsrep::mock_client& cc(T::cc); const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -89,7 +89,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE(transaction_rollback, T, const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -121,7 +121,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -163,7 +163,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -202,7 +202,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -240,7 +240,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -279,7 +279,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -315,7 +315,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_bf_before_cert_result_replay_success, replicating_client_fixture_sync_rm) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); sc.provider().certify_result_ = wsrep::provider::error_bf_abort; sc.provider().replay_result_ = wsrep::provider::success; @@ -335,7 +335,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_bf_before_cert_result_replay_cert_fail, replicating_client_fixture_sync_rm) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); sc.provider().certify_result_ = wsrep::provider::error_bf_abort; sc.provider().replay_result_ = wsrep::provider::error_certification_failed; @@ -361,7 +361,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -403,7 +403,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( wsrep::mock_client& cc(T::cc); const wsrep::transaction& tc(T::tc); - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -437,7 +437,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -478,7 +478,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -519,7 +519,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -560,7 +560,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -601,7 +601,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -642,7 +642,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -684,7 +684,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -725,7 +725,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -766,7 +766,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -798,7 +798,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( const wsrep::transaction& tc(T::tc); // Start a new transaction with ID 1 - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -819,7 +819,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( wsrep::client_state& cc(T::cc); const wsrep::transaction& tc(T::tc); - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); cc.after_statement(); BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec); @@ -842,7 +842,7 @@ BOOST_FIXTURE_TEST_CASE( replicating_client_fixture_autocommit) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); wsrep_test::bf_abort_unordered(cc); BOOST_REQUIRE(cc.before_commit()); @@ -862,7 +862,7 @@ BOOST_FIXTURE_TEST_CASE_TEMPLATE( wsrep::client_state& cc(T::cc); const wsrep::transaction& tc(T::tc); - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); cc.after_statement(); BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec); @@ -895,7 +895,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_1pc_bf_abort_after_after_command_after_result_sync_rm, replicating_client_fixture_sync_rm) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); cc.after_statement(); BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec); @@ -920,7 +920,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_1pc_bf_abort_after_after_command_after_result_async_rm, replicating_client_fixture_async_rm) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); cc.after_statement(); BOOST_REQUIRE(cc.state() == wsrep::client_state::s_exec); @@ -980,7 +980,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_applying_rollback, BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_1pc_commit, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); BOOST_REQUIRE(cc.before_commit() == 0); @@ -1000,7 +1000,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_batch_streaming_1pc_commit, { BOOST_REQUIRE(cc.enable_streaming( wsrep::streaming_context::row, 2) == 0); - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0); BOOST_REQUIRE(cc.after_row() == 0); @@ -1021,7 +1021,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_row_streaming_1pc_commit_two_statements, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); BOOST_REQUIRE(cc.after_statement() == 0); @@ -1043,7 +1043,7 @@ BOOST_FIXTURE_TEST_CASE( BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_rollback, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); BOOST_REQUIRE(cc.before_rollback() == 0); @@ -1060,7 +1060,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_rollback, BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_cert_fail_non_commit, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); sc.provider().certify_result_ = wsrep::provider::error_certification_failed; @@ -1080,7 +1080,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_cert_fail_non_commit, BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_cert_fail_commit, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); sc.provider().certify_result_ = wsrep::provider::error_certification_failed; @@ -1102,7 +1102,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_cert_fail_commit, BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_bf_abort_committing, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); BOOST_REQUIRE(cc.before_commit() == 0); @@ -1124,7 +1124,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_row_streaming_bf_abort_committing, BOOST_FIXTURE_TEST_CASE(transaction_byte_streaming_1pc_commit, streaming_client_fixture_byte) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); cc.bytes_generated_ = 1; BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); @@ -1143,7 +1143,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_byte_batch_streaming_1pc_commit, BOOST_REQUIRE( cc.enable_streaming( wsrep::streaming_context::bytes, 2) == 0); - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); cc.bytes_generated_ = 1; BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0); @@ -1166,7 +1166,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_statement_streaming_1pc_commit, BOOST_REQUIRE( cc.enable_streaming( wsrep::streaming_context::statement, 1) == 0); - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0); BOOST_REQUIRE(cc.after_statement() == 0); @@ -1187,7 +1187,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_statement_batch_streaming_1pc_commit, BOOST_REQUIRE( cc.enable_streaming( wsrep::streaming_context::statement, 2) == 0); - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0); BOOST_REQUIRE(cc.after_statement() == 0); @@ -1213,7 +1213,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_statement_streaming_cert_fail, BOOST_REQUIRE( cc.enable_streaming( wsrep::streaming_context::statement, 1) == 0); - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0); sc.provider().certify_result_ = wsrep::provider::error_certification_failed; diff --git a/test/transaction_test_2pc.cpp b/test/transaction_test_2pc.cpp index 0c85041..4861175 100644 --- a/test/transaction_test_2pc.cpp +++ b/test/transaction_test_2pc.cpp @@ -10,7 +10,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_2pc, replicating_client_fixture_2pc) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -38,7 +38,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_2pc_bf_before_before_prepare, replicating_client_fixture_2pc) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -65,7 +65,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_2pc_bf_before_after_prepare, replicating_client_fixture_2pc) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -95,7 +95,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_2pc_bf_after_after_prepare, replicating_client_fixture_2pc) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -123,7 +123,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_2pc_bf_before_before_commit, replicating_client_fixture_2pc) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -156,7 +156,7 @@ BOOST_FIXTURE_TEST_CASE( transaction_2pc_bf_during_commit_order_enter, replicating_client_fixture_2pc) { - cc.start_transaction(1); + cc.start_transaction(wsrep::transaction_id(1)); BOOST_REQUIRE(tc.active()); BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1)); BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing); @@ -187,7 +187,7 @@ BOOST_FIXTURE_TEST_CASE( BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_commit, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); BOOST_REQUIRE(cc.before_prepare() == 0); @@ -204,7 +204,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_commit, BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_commit_two_statements, streaming_client_fixture_row) { - BOOST_REQUIRE(cc.start_transaction(1) == 0); + BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0); BOOST_REQUIRE(cc.after_row() == 0); BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1); BOOST_REQUIRE(cc.after_statement() == 0);