mirror of
https://github.com/codership/wsrep-lib.git
synced 2025-07-05 03:41:13 +03:00
Squashed commit of the following:
commit3b419aa6e2
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Sun Feb 19 10:29:34 2023 +0200 Skip fetching config options if provider not loaded via wsrep-API commit044220cc06
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Wed Jul 13 10:31:03 2022 +0300 Operation context pointer for client state commiteeb05a9238
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Mon Jul 4 09:03:23 2022 +0300 Add unit test log in gitignore commit92a04070fc
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Sun May 8 12:45:36 2022 +0300 Added convenience method prev() to seqno commitf83ca1917e
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Sun May 1 16:37:24 2022 +0300 Pass victim context for provider on BF abort This change is needed for custom provider implementations to have a way to access the victim in the application context. Helper interface operation_context to pass caller context for service/provider callbacks in more type safe way. commit244eabe8cf
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Wed May 25 07:39:43 2022 +0300 Handle disconnecting state in on_sync() When disconnecting from the group, the sync event from the provider must not change the state back to synced. commitba8e23df0d
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Tue Mar 22 17:43:52 2022 +0200 Add provider position field to ws_meta and view Provider position is needed in coordinated recovery between application and provider. Pass the position info from provider to application to allow making it durable. commit53e60f64c9
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Sat Mar 19 14:45:57 2022 +0200 Reset TOI meta after releasing total order in provider This is to keep the TOI meta available in case the provider implementation needs it. commitbccb9997f2
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Mon Jan 3 11:19:58 2022 +0200 Fixed id ostream operator to print human readable ids commit6d0b37daaf
Author: Teemu Ollakka <teemu.ollakka@galeracluster.com> Date: Wed Dec 15 16:37:45 2021 +0200 Silence unused variable warning commit4b8616f3d1
Author: Denis Protivensky <denis.protivensky@galeracluster.com> Date: Wed Dec 15 16:43:31 2021 +0300 Fix provider loading in test for release builds commit6df17812d9
Author: Denis Protivensky <denis.protivensky@galeracluster.com> Date: Tue Dec 14 20:28:56 2021 +0300 Introduce set_provider_factory() method for server_state This allows injecting an application allocated provider into server_state. After this virtual provider getter is unnecessary. Made the getter normal method and fixed unit tests accordingly.
This commit is contained in:
@ -39,7 +39,8 @@ namespace
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(0),
|
||||
wsrep::provider::flag::start_transaction |
|
||||
wsrep::provider::flag::commit)
|
||||
wsrep::provider::flag::commit,
|
||||
0)
|
||||
, cluster_id("1")
|
||||
, bootstrap_view()
|
||||
, second_view()
|
||||
@ -55,7 +56,8 @@ namespace
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members);
|
||||
members,
|
||||
0);
|
||||
|
||||
members.push_back(wsrep::view::member(
|
||||
wsrep::id("s2"), "s2", ""));
|
||||
@ -65,7 +67,8 @@ namespace
|
||||
0, // capabilities
|
||||
1, // own index
|
||||
1, // protocol version
|
||||
members);
|
||||
members,
|
||||
0);
|
||||
|
||||
members.push_back(wsrep::view::member(
|
||||
wsrep::id("s3"), "s3", ""));
|
||||
@ -76,7 +79,8 @@ namespace
|
||||
0, // capabilities
|
||||
1, // own index
|
||||
1, // protocol version
|
||||
members);
|
||||
members,
|
||||
0);
|
||||
|
||||
cc.open(cc.id());
|
||||
BOOST_REQUIRE(cc.before_command() == 0);
|
||||
@ -132,7 +136,8 @@ namespace
|
||||
0, // capabilities
|
||||
-1, // own_index
|
||||
0, // protocol ver
|
||||
std::vector<wsrep::view::member>() // members
|
||||
std::vector<wsrep::view::member>(),// members
|
||||
0
|
||||
);
|
||||
ss.on_view(view, &hps);
|
||||
}
|
||||
@ -258,7 +263,7 @@ BOOST_FIXTURE_TEST_CASE(server_state_applying_1pc_rollback,
|
||||
applying_server_fixture)
|
||||
{
|
||||
/* make sure default success result is flipped to error_fatal */
|
||||
ss.provider().commit_order_leave_result_ = wsrep::provider::success;
|
||||
ss.mock_provider().commit_order_leave_result_ = wsrep::provider::success;
|
||||
hps.fail_next_applying_ = true;
|
||||
char buf[1] = { 1 };
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, ws_meta,
|
||||
@ -273,7 +278,7 @@ BOOST_FIXTURE_TEST_CASE(server_state_applying_2pc_rollback,
|
||||
applying_server_fixture)
|
||||
{
|
||||
/* make sure default success result is flipped to error_fatal */
|
||||
ss.provider().commit_order_leave_result_ = wsrep::provider::success;
|
||||
ss.mock_provider().commit_order_leave_result_ = wsrep::provider::success;
|
||||
hps.do_2pc_ = true;
|
||||
hps.fail_next_applying_ = true;
|
||||
char buf[1] = { 1 };
|
||||
@ -290,7 +295,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_streaming, applying_server_fixture)
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(0),
|
||||
wsrep::provider::flag::start_transaction);
|
||||
wsrep::provider::flag::start_transaction,
|
||||
0);
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, ws_meta,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
BOOST_REQUIRE(ss.find_streaming_applier(
|
||||
@ -300,6 +306,7 @@ BOOST_FIXTURE_TEST_CASE(server_state_streaming, applying_server_fixture)
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(1),
|
||||
0,
|
||||
0);
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, ws_meta,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -308,7 +315,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_streaming, applying_server_fixture)
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(1),
|
||||
wsrep::provider::flag::commit);
|
||||
wsrep::provider::flag::commit,
|
||||
0);
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, ws_meta,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
BOOST_REQUIRE(ss.find_streaming_applier(
|
||||
@ -413,7 +421,8 @@ BOOST_FIXTURE_TEST_CASE(
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members);
|
||||
members,
|
||||
0);
|
||||
ss.on_connect(view);
|
||||
BOOST_REQUIRE(ss.state() == wsrep::server_state::s_connected);
|
||||
// As storage engines have been initialized, there should not be
|
||||
@ -573,7 +582,8 @@ BOOST_FIXTURE_TEST_CASE(
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members);
|
||||
members,
|
||||
0);
|
||||
ss.on_connect(view);
|
||||
BOOST_REQUIRE(ss.state() == wsrep::server_state::s_connected);
|
||||
// As storage engines have been initialized, there should not be
|
||||
@ -734,7 +744,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(1),
|
||||
wsrep::provider::flag::start_transaction);
|
||||
wsrep::provider::flag::start_transaction,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_s2,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -747,7 +758,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(2),
|
||||
wsrep::provider::flag::start_transaction);
|
||||
wsrep::provider::flag::start_transaction,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_s3,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -763,7 +775,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members), &hps);
|
||||
members,
|
||||
0), &hps);
|
||||
|
||||
// transaction from s2 is still present
|
||||
BOOST_REQUIRE(ss.find_streaming_applier(
|
||||
@ -781,7 +794,7 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members), &hps);
|
||||
members, 0), &hps);
|
||||
|
||||
// no streaming appliers are closed on non-primary view,
|
||||
// so transaction from s2 is still present
|
||||
@ -796,7 +809,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members), &hps);
|
||||
members,
|
||||
0), &hps);
|
||||
|
||||
// transaction s2 is still present after non-primary view
|
||||
BOOST_REQUIRE(ss.find_streaming_applier(
|
||||
@ -810,7 +824,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members), &hps);
|
||||
members,
|
||||
0), &hps);
|
||||
|
||||
// finally, transaction from s2 is still present (part of primary view)
|
||||
// and transaction from s3 is gone
|
||||
@ -825,7 +840,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_close_orphaned_transactions,
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(3),
|
||||
wsrep::provider::flag::commit);
|
||||
wsrep::provider::flag::commit,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_commit_s2,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -852,7 +868,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_equal_consecutive_views,
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(1),
|
||||
wsrep::provider::flag::start_transaction);
|
||||
wsrep::provider::flag::start_transaction,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_s2,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -865,7 +882,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_equal_consecutive_views,
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(2),
|
||||
wsrep::provider::flag::start_transaction);
|
||||
wsrep::provider::flag::start_transaction,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_s3,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -879,7 +897,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_equal_consecutive_views,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
ss.current_view().members()), &hps);
|
||||
ss.current_view().members(),
|
||||
0), &hps);
|
||||
|
||||
// transaction from s2 and s3 are gone
|
||||
BOOST_REQUIRE(not ss.find_streaming_applier(
|
||||
@ -908,7 +927,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_xa_not_orphaned,
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(1),
|
||||
wsrep::provider::flag::start_transaction |
|
||||
wsrep::provider::flag::prepare);
|
||||
wsrep::provider::flag::prepare,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_s3,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
@ -925,7 +945,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_xa_not_orphaned,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members), &hps);
|
||||
members,
|
||||
0), &hps);
|
||||
|
||||
// transaction from s3 is still present
|
||||
BOOST_REQUIRE(ss.find_streaming_applier(
|
||||
@ -939,7 +960,8 @@ BOOST_FIXTURE_TEST_CASE(server_state_xa_not_orphaned,
|
||||
0, // capabilities
|
||||
0, // own index
|
||||
1, // protocol version
|
||||
members), &hps);
|
||||
members,
|
||||
0), &hps);
|
||||
|
||||
// transaction from s3 is still present
|
||||
BOOST_REQUIRE(ss.find_streaming_applier(
|
||||
@ -951,10 +973,22 @@ BOOST_FIXTURE_TEST_CASE(server_state_xa_not_orphaned,
|
||||
wsrep::transaction_id(1),
|
||||
wsrep::client_id(1)),
|
||||
wsrep::seqno(3),
|
||||
wsrep::provider::flag::commit);
|
||||
wsrep::provider::flag::commit,
|
||||
0);
|
||||
|
||||
BOOST_REQUIRE(ss.on_apply(hps, ws_handle, meta_commit_s3,
|
||||
wsrep::const_buffer("1", 1)) == 0);
|
||||
BOOST_REQUIRE(not ss.find_streaming_applier(
|
||||
meta_commit_s3.server_id(), meta_commit_s3.transaction_id()));
|
||||
}
|
||||
|
||||
BOOST_FIXTURE_TEST_CASE(server_state_sync_in_disconnecting,
|
||||
sst_first_server_fixture)
|
||||
{
|
||||
bootstrap();
|
||||
ss.disconnect();
|
||||
BOOST_REQUIRE(ss.state() == wsrep::server_state::s_disconnecting);
|
||||
// Synced event from the provider must not change the state.
|
||||
ss.on_sync();
|
||||
BOOST_REQUIRE(ss.state() == wsrep::server_state::s_disconnecting);
|
||||
}
|
||||
|
Reference in New Issue
Block a user