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

Fix attempt to replicate empty fragments

* Adds method wsrep::transaction::streaming_step() so that there is a
  single place where streaming context unit counter is udpated.
  The method also checks that some data has been generated before
  attempting fragment replication.
* Emit a warning if there is an attempt to replicate a fragment and
  there is no data to replicate.
This commit is contained in:
Daniele Sciascia
2019-01-07 11:45:28 +01:00
parent a9e2fdccfc
commit 4ac15e4349
7 changed files with 106 additions and 41 deletions

View File

@ -259,7 +259,7 @@ namespace
// Verify initial state
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
cc.enable_streaming(wsrep::streaming_context::row, 1);
cc.enable_streaming(wsrep::streaming_context::statement, 1);
}
wsrep::mock_server_service server_service;

View File

@ -200,6 +200,12 @@ namespace wsrep
: mock_client_state(server_state, *this, id, mode)
, mock_client_service(static_cast<mock_client_state&>(*this))
{ }
int after_row()
{
bytes_generated_++;
return wsrep::client_state::after_row();
}
};
}

View File

@ -1190,10 +1190,8 @@ BOOST_FIXTURE_TEST_CASE(transaction_byte_batch_streaming_1pc_commit,
cc.enable_streaming(
wsrep::streaming_context::bytes, 2) == 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);
cc.bytes_generated_ = 2;
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1);
BOOST_REQUIRE(cc.before_commit() == 0);
@ -1206,12 +1204,31 @@ BOOST_FIXTURE_TEST_CASE(transaction_byte_batch_streaming_1pc_commit,
}
BOOST_FIXTURE_TEST_CASE(transaction_statement_streaming_statement_with_no_effect,
streaming_client_fixture_statement)
{
BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0);
BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.after_statement() == 0);
BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 0);
BOOST_REQUIRE(cc.after_row() == 0);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.after_statement() == 0);
BOOST_REQUIRE(tc.streaming_context().fragments_certified() == 1);
BOOST_REQUIRE(cc.before_statement() == 0);
BOOST_REQUIRE(cc.before_commit() == 0);
BOOST_REQUIRE(cc.ordered_commit() == 0);
BOOST_REQUIRE(cc.after_commit() == 0);
BOOST_REQUIRE(cc.after_statement() == 0);
BOOST_REQUIRE(sc.provider().fragments() == 2);
BOOST_REQUIRE(sc.provider().start_fragments() == 1);
BOOST_REQUIRE(sc.provider().commit_fragments() == 1);
}
BOOST_FIXTURE_TEST_CASE(transaction_statement_streaming_1pc_commit,
streaming_client_fixture_statement)
{
BOOST_REQUIRE(
cc.enable_streaming(
wsrep::streaming_context::statement, 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);
@ -1254,11 +1271,8 @@ BOOST_FIXTURE_TEST_CASE(transaction_statement_batch_streaming_1pc_commit,
}
BOOST_FIXTURE_TEST_CASE(transaction_statement_streaming_cert_fail,
streaming_client_fixture_row)
streaming_client_fixture_statement)
{
BOOST_REQUIRE(
cc.enable_streaming(
wsrep::streaming_context::statement, 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);