From c487d11f862c7b3548c322257f0fa60024e96f2c Mon Sep 17 00:00:00 2001 From: Pekka Lampio Date: Tue, 23 Feb 2021 18:52:40 +0200 Subject: [PATCH] Changes: 1) Add initialization for trx->xid in InnoDB trx pool 2) Add server UUID in the XID of InnoDB SR transactions 3) Modify trx_recover_for_mysql_callback() so that recovered InnoDB SR transactions are not made visible to MySQL as recovered XA transactions. 4) Modify how SR transactions are detected and the wsrep_is_sr flag is set for InnoDB SR transactions. --- include/wsrep/client_state.hpp | 11 ++++++++++- include/wsrep/storage_service.hpp | 4 ++++ include/wsrep/transaction.hpp | 3 +++ src/server_state.cpp | 9 ++++++++- src/transaction.cpp | 25 +++++++++++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) diff --git a/include/wsrep/client_state.hpp b/include/wsrep/client_state.hpp index 3c518d6..9403bf2 100644 --- a/include/wsrep/client_state.hpp +++ b/include/wsrep/client_state.hpp @@ -926,7 +926,16 @@ namespace wsrep { return transaction_; } - +#ifdef WITH_WSREP_SR_SPEEDUP + /** + * Return a reference to the transaction associated + * with the client state. + */ + wsrep::transaction& transaction() + { + return transaction_; + } +#endif /* WITH_WSREP_SR_SPEEDUP */ const wsrep::ws_meta& toi_meta() const { return toi_meta_; diff --git a/include/wsrep/storage_service.hpp b/include/wsrep/storage_service.hpp index 6f461a7..3ef43d8 100644 --- a/include/wsrep/storage_service.hpp +++ b/include/wsrep/storage_service.hpp @@ -82,6 +82,10 @@ namespace wsrep */ virtual int remove_fragments() = 0; +#ifdef WITH_WSREP_SR_SPEEDUP + int set_fragments_from_table() {return 0;}; +#endif /* WITH_WSREP_SR_SPEEDUP */ + /** * Commit the transaction. */ diff --git a/include/wsrep/transaction.hpp b/include/wsrep/transaction.hpp index f9d1659..a3480f0 100644 --- a/include/wsrep/transaction.hpp +++ b/include/wsrep/transaction.hpp @@ -142,6 +142,9 @@ namespace wsrep void xa_detach(); int xa_replay(wsrep::unique_lock&); +#ifdef WITH_WSREP_SR_SPEEDUP + int set_fragments_from_table(); +#endif /* WITH_WSREP_SR_SPEEDUP */ bool pa_unsafe() const { return pa_unsafe_; } void pa_unsafe(bool pa_unsafe) { pa_unsafe_ = pa_unsafe; } diff --git a/src/server_state.cpp b/src/server_state.cpp index 8a2a586..1f17b71 100644 --- a/src/server_state.cpp +++ b/src/server_state.cpp @@ -99,6 +99,10 @@ static int apply_fragment(wsrep::server_state& server_state, wsrep::high_priority_switch sw(high_priority_service, *streaming_applier); apply_err = streaming_applier->apply_write_set(ws_meta, data, err); +#ifdef DEBUG_SR_SPEEDUP + wsrep::log_info() << "server_state: apply_fragment, line = " + << __LINE__ << ", apply_err = " << apply_err; +#endif /* DEBUG_SR_SPEEDUP */ if (!apply_err) { assert(err.size() == 0); @@ -127,7 +131,10 @@ static int apply_fragment(wsrep::server_state& server_state, } } } - +#ifdef DEBUG_SR_SPEEDUP + wsrep::log_info() << "server_state: apply_fragment, line = " + << __LINE__ << ", ret = " << ret; +#endif /* DEBUG_SR_SPEEDUP */ if (!ret) { if (!apply_err) diff --git a/src/transaction.cpp b/src/transaction.cpp index 345b995..7d15296 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -214,6 +214,12 @@ void wsrep::transaction::fragment_applied(wsrep::seqno seqno) { assert(active()); streaming_context_.applied(seqno); +#ifdef DEBUG_SR_SPEEDUP + wsrep::log_info() << "wsrep::transaction::fragment_applied: " + << "SR context = " << (void *)&streaming_context_ + << ", size = " << streaming_context_.fragments_stored() + << ", seqno = " << seqno.get(); +#endif /* DEBUG_SR_SPEEDUP */ } int wsrep::transaction::prepare_for_ordering( @@ -1299,6 +1305,24 @@ int wsrep::transaction::xa_replay(wsrep::unique_lock& lock) return ret; } +#ifdef WITH_WSREP_SR_SPEEDUP +int wsrep::transaction::set_fragments_from_table() +{ + scoped_storage_service + sr_scope( + client_service_, + server_service_.storage_service(client_service_), + storage_service_deleter(server_service_)); + wsrep::storage_service& storage_service( + sr_scope.storage_service()); + + int rcode = storage_service.set_fragments_from_table(); + + return (rcode); +} +#endif /* WITH_WSREP_SR_SPEEDUP */ + + //////////////////////////////////////////////////////////////////////////////// // Private // //////////////////////////////////////////////////////////////////////////////// @@ -1634,6 +1658,7 @@ int wsrep::transaction::certify_fragment( else { streaming_context_.stored(sr_ws_meta.seqno()); + } client_service_.debug_crash( "crash_replicate_fragment_success");