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

Minimize client_service interface for XA

Remove methods `is_xa()`, `is_xa_prepare()`, and `xid()` from
client_service interface. Instead, transactions are explicitly
assigned their xid, through at start of XA.
This commit is contained in:
Daniele Sciascia
2019-07-30 11:25:38 +02:00
parent 052247144f
commit 5d18ce3e75
7 changed files with 85 additions and 126 deletions

View File

@ -62,8 +62,6 @@ namespace wsrep
: wsrep::client_service()
, is_autocommit_()
, do_2pc_()
, is_xa_()
, is_xa_prepare_()
// , fail_next_applying_()
// , fail_next_toi_()
, bf_abort_during_wait_()
@ -131,21 +129,6 @@ namespace wsrep
void cleanup_transaction() WSREP_OVERRIDE { }
bool is_xa() const WSREP_OVERRIDE
{
return is_xa_;
}
bool is_xa_prepare() const WSREP_OVERRIDE
{
return is_xa_prepare_;
}
std::string xid() const WSREP_OVERRIDE
{
return "";
}
size_t bytes_generated() const WSREP_OVERRIDE
{
return bytes_generated_;
@ -197,8 +180,6 @@ namespace wsrep
//
bool is_autocommit_;
bool do_2pc_;
bool is_xa_;
bool is_xa_prepare_;
// bool fail_next_applying_;
// bool fail_next_toi_;
bool bf_abort_during_wait_;

View File

@ -8,14 +8,12 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa,
replicating_client_fixture_sync_rm)
{
BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0);
cc.is_xa_ = true;
cc.assign_xid("test xid");
BOOST_REQUIRE(tc.active());
BOOST_REQUIRE(tc.id() == wsrep::transaction_id(1));
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
cc.is_xa_prepare_ = true;
BOOST_REQUIRE(cc.before_prepare() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_preparing);
BOOST_REQUIRE(tc.ordered() == false);
@ -28,8 +26,6 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa,
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().fragments() == 1);
cc.is_xa_prepare_ = false;
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_committing);
BOOST_REQUIRE(cc.ordered_commit() == 0);
@ -38,7 +34,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa,
BOOST_REQUIRE(tc.certified());
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_committed);
// XA PRERAPRE and XA COMMIT fragments
// XA PREPARE and XA COMMIT fragments
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
@ -56,8 +52,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa,
BOOST_FIXTURE_TEST_CASE(transaction_xa_applying,
applying_client_fixture)
{
cc.is_xa_ = true;
cc.is_xa_prepare_ = true;
cc.assign_xid("test xid");
BOOST_REQUIRE(cc.before_prepare() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_preparing);
@ -67,8 +62,6 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa_applying,
BOOST_REQUIRE(cc.after_prepare() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_prepared);
cc.is_xa_prepare_ = false;
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_committing);
BOOST_REQUIRE(cc.ordered_commit() == 0);
@ -92,7 +85,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa_sr,
streaming_client_fixture_byte)
{
BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0);
cc.is_xa_ = true;
cc.assign_xid("test xid");
cc.bytes_generated_ = 1;
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1);
@ -103,8 +96,6 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa_sr,
BOOST_REQUIRE(tc.active());
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
cc.is_xa_prepare_ = true;
BOOST_REQUIRE(cc.before_prepare() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_preparing);
BOOST_REQUIRE(tc.ordered() == false);
@ -114,8 +105,6 @@ BOOST_FIXTURE_TEST_CASE(transaction_xa_sr,
// XA PREPARE fragment
BOOST_REQUIRE(sc.provider().fragments() == 2);
cc.is_xa_prepare_ = false;
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_committing);
BOOST_REQUIRE(cc.ordered_commit() == 0);