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

Add support for custom provider implementation

- Add a set_provider_factory() method to server_state to allow
  injecting provider factory which will be called when the
  provider is loaded.

Other related changes:
- Implement to_string() helper method for id class.
- Fix id ostream operator human readable id printing.
- Pass victim client_service as an argument to provider::bf_abort()
  to allow passing victim context to custom provider.
- Implement prev() helper method for seqno class.
- Make server_state recover_streaming_appliers_if_not_recovered()
  public. In some recovery scenarios the method must be called outside
  of server_state internal code paths.
- Add storage_service requires_globals() method. The storage service
  implementation may override this to return false if changing to
  storage service context does not require store/reset globals.
- Change view final() to also require that the view status is not
  primary for the view to be final. Also change the method name to
  is_final() to avoid confusion with C++ final identifier.
- Fixes to server state handling in disconnecting and disconnected
  states.
- Keep TOI meta data over whole TOI critical section.

Co-authored-by: Denis Protivensky <denis.protivensky@galeracluster.com>
This commit is contained in:
Teemu Ollakka
2025-01-13 16:06:28 +02:00
parent 51a0b0ab4f
commit 5ea78de6c2
26 changed files with 242 additions and 131 deletions

View File

@ -1,5 +1,5 @@
/*
* Copyright (C) 2018-2019 Codership Oy <info@codership.com>
* Copyright (C) 2018-2021 Codership Oy <info@codership.com>
*
* This file is part of wsrep-lib.
*
@ -22,8 +22,7 @@
//
// Test a succesful 2PC transaction lifecycle
//
BOOST_FIXTURE_TEST_CASE(transaction_2pc,
replicating_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc, replicating_client_fixture_2pc)
{
cc.start_transaction(wsrep::transaction_id(1));
BOOST_REQUIRE(tc.active());
@ -52,9 +51,8 @@ BOOST_FIXTURE_TEST_CASE(transaction_2pc,
//
// Test a 2PC transaction which gets BF aborted before before_prepare
//
BOOST_FIXTURE_TEST_CASE(
transaction_2pc_bf_before_before_prepare,
replicating_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc_bf_before_before_prepare,
replicating_client_fixture_2pc)
{
cc.start_transaction(wsrep::transaction_id(1));
BOOST_REQUIRE(tc.active());
@ -69,7 +67,7 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_aborting);
BOOST_REQUIRE(cc.after_rollback() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_aborted);
BOOST_REQUIRE(cc.after_statement() );
BOOST_REQUIRE(cc.after_statement());
BOOST_REQUIRE(tc.active() == false);
BOOST_REQUIRE(tc.ordered() == false);
BOOST_REQUIRE(tc.certified() == false);
@ -79,9 +77,8 @@ BOOST_FIXTURE_TEST_CASE(
//
// Test a 2PC transaction which gets BF aborted before before_prepare
//
BOOST_FIXTURE_TEST_CASE(
transaction_2pc_bf_before_after_prepare,
replicating_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc_bf_before_after_prepare,
replicating_client_fixture_2pc)
{
cc.start_transaction(wsrep::transaction_id(1));
BOOST_REQUIRE(tc.active());
@ -110,9 +107,8 @@ BOOST_FIXTURE_TEST_CASE(
// Test a 2PC transaction which gets BF aborted after_prepare() and
// the rollback takes place before entering before_commit().
//
BOOST_FIXTURE_TEST_CASE(
transaction_2pc_bf_after_after_prepare,
replicating_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc_bf_after_after_prepare,
replicating_client_fixture_2pc)
{
cc.start_transaction(wsrep::transaction_id(1));
BOOST_REQUIRE(tc.active());
@ -139,9 +135,8 @@ BOOST_FIXTURE_TEST_CASE(
// Test a 2PC transaction which gets BF aborted between after_prepare()
// and before_commit()
//
BOOST_FIXTURE_TEST_CASE(
transaction_2pc_bf_before_before_commit,
replicating_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc_bf_before_before_commit,
replicating_client_fixture_2pc)
{
cc.start_transaction(wsrep::transaction_id(1));
BOOST_REQUIRE(tc.active());
@ -168,14 +163,12 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(cc.current_error() == wsrep::e_success);
}
//
// Test a 2PC transaction which gets BF aborted when trying to grab
// commit order.
//
BOOST_FIXTURE_TEST_CASE(
transaction_2pc_bf_during_commit_order_enter,
replicating_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc_bf_during_commit_order_enter,
replicating_client_fixture_2pc)
{
cc.start_transaction(wsrep::transaction_id(1));
BOOST_REQUIRE(tc.active());
@ -183,7 +176,8 @@ BOOST_FIXTURE_TEST_CASE(
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_executing);
BOOST_REQUIRE(cc.before_prepare() == 0);
BOOST_REQUIRE(cc.after_prepare() == 0);
sc.provider().commit_order_enter_result_ = wsrep::provider::error_bf_abort;
sc.provider().commit_order_enter_result_
= wsrep::provider::error_bf_abort;
BOOST_REQUIRE(cc.before_commit());
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_must_replay);
BOOST_REQUIRE(cc.will_replay_called() == true);
@ -205,7 +199,6 @@ BOOST_FIXTURE_TEST_CASE(
// STREAMING REPLICATION //
///////////////////////////////////////////////////////////////////////////////
BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_commit,
streaming_client_fixture_row)
{
@ -251,8 +244,9 @@ BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_commit_two_statements,
// internally. This will cause the transaction to leave before_prepare()
// in aborted state.
//
BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_bf_abort_during_fragment_removal,
streaming_client_fixture_row)
BOOST_FIXTURE_TEST_CASE(
transaction_streaming_2pc_bf_abort_during_fragment_removal,
streaming_client_fixture_row)
{
BOOST_REQUIRE(cc.start_transaction(wsrep::transaction_id(1)) == 0);
BOOST_REQUIRE(cc.after_row() == 0);
@ -270,8 +264,7 @@ BOOST_FIXTURE_TEST_CASE(transaction_streaming_2pc_bf_abort_during_fragment_remov
// APPLYING //
///////////////////////////////////////////////////////////////////////////////
BOOST_FIXTURE_TEST_CASE(transaction_2pc_applying,
applying_client_fixture_2pc)
BOOST_FIXTURE_TEST_CASE(transaction_2pc_applying, applying_client_fixture_2pc)
{
BOOST_REQUIRE(cc.before_prepare() == 0);
BOOST_REQUIRE(tc.state() == wsrep::transaction::s_preparing);