diff --git a/dbsim/db_client.cpp b/dbsim/db_client.cpp index c2cbfdf..e9ac3a4 100644 --- a/dbsim/db_client.cpp +++ b/dbsim/db_client.cpp @@ -16,7 +16,7 @@ db::client::client(db::server& server, , server_(server) , server_state_(server.server_state()) , client_state_(mutex_, this, server_state_, client_service_, client_id, mode) - , client_service_(server_state_.provider(), client_state_) + , client_service_(client_state_) , se_trx_(server.storage_engine()) , stats_() { } diff --git a/dbsim/db_client_service.cpp b/dbsim/db_client_service.cpp index 6d28d1e..3979ef7 100644 --- a/dbsim/db_client_service.cpp +++ b/dbsim/db_client_service.cpp @@ -38,8 +38,9 @@ enum wsrep::provider::status db::client_service::replay() { wsrep::high_priority_context high_priority_context(client_state_); - auto ret(provider_.replay(client_state_.transaction().ws_handle(), - &client_state_)); + auto ret(client_state_.provider().replay( + client_state_.transaction().ws_handle(), + &client_state_)); if (ret == wsrep::provider::success) { ++client_state_.client()->stats_.replays; diff --git a/dbsim/db_client_service.hpp b/dbsim/db_client_service.hpp index 993f029..a53cfd9 100644 --- a/dbsim/db_client_service.hpp +++ b/dbsim/db_client_service.hpp @@ -15,9 +15,8 @@ namespace db class client_service : public wsrep::client_service { public: - client_service(wsrep::provider& provider, - db::client_state& client_state) - : wsrep::client_service(provider) + client_service(db::client_state& client_state) + : wsrep::client_service() , client_state_(client_state) { } diff --git a/include/wsrep/client_service.hpp b/include/wsrep/client_service.hpp index 6e27d07..4111fa2 100644 --- a/include/wsrep/client_service.hpp +++ b/include/wsrep/client_service.hpp @@ -27,8 +27,8 @@ namespace wsrep class client_service : public wsrep::transaction_termination_service { public: - client_service(wsrep::provider& provider) - : provider_(provider) { } + client_service() { } + /** * */ @@ -145,9 +145,6 @@ namespace wsrep * been enabled. */ virtual void debug_crash(const char* crash_point) = 0; - - protected: - wsrep::provider& provider_; }; /** diff --git a/include/wsrep/transaction.hpp b/include/wsrep/transaction.hpp index 6cd4a40..226888e 100644 --- a/include/wsrep/transaction.hpp +++ b/include/wsrep/transaction.hpp @@ -129,6 +129,7 @@ namespace wsrep transaction(const transaction&); transaction operator=(const transaction&); + wsrep::provider& provider(); void flags(int flags) { flags_ = flags; } int certify_fragment(wsrep::unique_lock&); int certify_commit(wsrep::unique_lock&); @@ -137,7 +138,6 @@ namespace wsrep void cleanup(); void debug_log_state(const char*) const; - wsrep::provider& provider_; wsrep::server_service& server_service_; wsrep::client_service& client_service_; wsrep::client_state& client_state_; diff --git a/src/transaction.cpp b/src/transaction.cpp index 2c9b0ed..01d0cab 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -23,8 +23,7 @@ wsrep::transaction::transaction( wsrep::client_state& client_state) - : provider_(client_state.provider()) - , server_service_(client_state.server_state().server_service()) + : server_service_(client_state.server_state().server_service()) , client_service_(client_state.client_service()) , client_state_(client_state) , id_(transaction_id::invalid()) @@ -60,7 +59,7 @@ int wsrep::transaction::start_transaction( case wsrep::client_state::m_high_priority: return 0; case wsrep::client_state::m_replicating: - return provider_.start_transaction(ws_handle_); + return provider().start_transaction(ws_handle_); default: assert(0); return 1; @@ -98,13 +97,13 @@ int wsrep::transaction::start_replaying(const wsrep::ws_meta& ws_meta) int wsrep::transaction::append_key(const wsrep::key& key) { /** @todo Collect table level keys for SR commit */ - return provider_.append_key(ws_handle_, key); + return provider().append_key(ws_handle_, key); } int wsrep::transaction::append_data(const wsrep::const_buffer& data) { - return provider_.append_data(ws_handle_, data); + return provider().append_data(ws_handle_, data); } int wsrep::transaction::after_row() @@ -252,7 +251,7 @@ int wsrep::transaction::before_commit() case wsrep::client_state::m_local: if (ordered()) { - ret = provider_.commit_order_enter(ws_handle_, ws_meta_); + ret = provider().commit_order_enter(ws_handle_, ws_meta_); } break; case wsrep::client_state::m_replicating: @@ -289,7 +288,7 @@ int wsrep::transaction::before_commit() assert(ordered()); lock.unlock(); enum wsrep::provider::status - status(provider_.commit_order_enter(ws_handle_, ws_meta_)); + status(provider().commit_order_enter(ws_handle_, ws_meta_)); lock.lock(); switch (status) { @@ -321,7 +320,7 @@ int wsrep::transaction::before_commit() { ret = 0; } - ret = ret || provider_.commit_order_enter(ws_handle_, ws_meta_); + ret = ret || provider().commit_order_enter(ws_handle_, ws_meta_); if (ret) { state(lock, s_must_abort); @@ -341,7 +340,7 @@ int wsrep::transaction::ordered_commit() debug_log_state("ordered_commit_enter"); assert(state() == s_committing); assert(ordered()); - int ret(provider_.commit_order_leave(ws_handle_, ws_meta_)); + int ret(provider().commit_order_leave(ws_handle_, ws_meta_)); // Should always succeed assert(ret == 0); state(lock, s_ordered_commit); @@ -370,7 +369,7 @@ int wsrep::transaction::after_commit() // Nothing to do break; case wsrep::client_state::m_replicating: - ret = provider_.release(ws_handle_); + ret = provider().release(ws_handle_); break; case wsrep::client_state::m_high_priority: break; @@ -428,7 +427,7 @@ int wsrep::transaction::before_rollback() case s_aborting: if (is_streaming()) { - provider_.rollback(id_.get()); + provider().rollback(id_.get()); } break; case s_must_replay: @@ -515,7 +514,7 @@ int wsrep::transaction::after_statement() switch (replay_ret) { case wsrep::provider::success: - provider_.release(ws_handle_); + provider().release(ws_handle_); break; case wsrep::provider::error_certification_failed: client_state_.override_error( @@ -550,10 +549,10 @@ int wsrep::transaction::after_statement() { if (ordered()) { - ret = provider_.commit_order_enter(ws_handle_, ws_meta_); - if (ret == 0) provider_.commit_order_leave(ws_handle_, ws_meta_); + ret = provider().commit_order_enter(ws_handle_, ws_meta_); + if (ret == 0) provider().commit_order_leave(ws_handle_, ws_meta_); } - provider_.release(ws_handle_); + provider().release(ws_handle_); } if (state() != s_executing) @@ -647,6 +646,11 @@ bool wsrep::transaction::bf_abort( // Private // //////////////////////////////////////////////////////////////////////////////// +inline wsrep::provider& wsrep::transaction::provider() +{ + return client_state_.server_state().provider(); +} + void wsrep::transaction::state( wsrep::unique_lock& lock __attribute__((unused)), enum wsrep::transaction::state next_state) @@ -745,7 +749,7 @@ int wsrep::transaction::certify_fragment( } enum wsrep::provider::status - cert_ret(provider_.certify(client_state_.id().get(), + cert_ret(provider().certify(client_state_.id().get(), sr_transaction.ws_handle_, flags_, sr_transaction.ws_meta_)); @@ -826,7 +830,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().get(), ws_handle_, flags(), ws_meta_)); @@ -935,7 +939,7 @@ void wsrep::transaction::streaming_rollback() sac->adopt_transaction(*this); streaming_context_.cleanup(); // Replicate rollback fragment - provider_.rollback(id_.get()); + provider().rollback(id_.get()); } void wsrep::transaction::clear_fragments() diff --git a/test/mock_client_state.hpp b/test/mock_client_state.hpp index f93d2b4..0265308 100644 --- a/test/mock_client_state.hpp +++ b/test/mock_client_state.hpp @@ -43,7 +43,7 @@ namespace wsrep { public: mock_client_service(wsrep::mock_client_state& client_state) - : wsrep::client_service(client_state.provider()) + : wsrep::client_service() , is_autocommit_() , do_2pc_() , fail_next_applying_() @@ -89,8 +89,9 @@ namespace wsrep replay() WSREP_OVERRIDE { enum wsrep::provider::status ret( - provider_.replay(client_state_.transaction().ws_handle(), - &client_state_)); + client_state_.provider().replay( + client_state_.transaction().ws_handle(), + &client_state_)); ++replays_; return ret; } diff --git a/wsrep b/wsrep index e12a9dd..eb7d6b8 160000 --- a/wsrep +++ b/wsrep @@ -1 +1 @@ -Subproject commit e12a9dd89c18f7b426cd724cbdb28f213268b42c +Subproject commit eb7d6b8dd1f53006bdc69e451b67039836fd3c3a