diff --git a/include/wsrep/client_service.hpp b/include/wsrep/client_service.hpp index 78d097d..f5038a6 100644 --- a/include/wsrep/client_service.hpp +++ b/include/wsrep/client_service.hpp @@ -220,7 +220,7 @@ namespace wsrep #ifdef WITH_WSREP_SR_SPEEDUP /** - * Return the binlog cache for the currently execution + * Return the binlog cache for the currently executing * transaction or a NULL pointer if no such cache exists. */ virtual void *get_binlog_cache() = 0; diff --git a/include/wsrep/transaction.hpp b/include/wsrep/transaction.hpp index 942d216..d8ab30a 100644 --- a/include/wsrep/transaction.hpp +++ b/include/wsrep/transaction.hpp @@ -145,6 +145,44 @@ namespace wsrep #ifdef WITH_WSREP_SR_SPEEDUP int set_fragments_from_table(); void *get_binlog_cache(); + /* state of Streaming Replication Speedup feature for the + transaction. This describes the relationship of this WSREP + transaction and the underlying InnoDB transaction. + */ + enum sr_state + { + /* this is not an SR Speedup transaction */ + sr_state_none, + /* this is an SR Speedup transaction, but SR XID is not set + for the underlying InnoDB transaction + */ + sr_state_require_xid, + /* this is an SR Speedup transaction, and SR XID is set + for the underlying InnoDB transaction + */ + sr_state_xid_set + }; + static const int n_sr_states = sr_state_xid_set + 1; + enum sr_state sr_state() const + { return sr_state_; } + void require_sr_xid() + { + if (sr_state_ == sr_state_none) { + sr_state_ = sr_state_require_xid; + } + } + void sr_xid_was_set() + { + sr_state_ = sr_state_xid_set; + } + bool sr_xid_is_required() + { + return sr_state_ == sr_state_require_xid; + } + bool sr_xid_is_set() + { + return sr_state_ == sr_state_xid_set; + } #endif /* WITH_WSREP_SR_SPEEDUP */ bool pa_unsafe() const { return pa_unsafe_; } @@ -277,6 +315,9 @@ namespace wsrep wsrep::sr_key_set sr_keys_; wsrep::mutable_buffer apply_error_buf_; wsrep::xid xid_; +#ifdef WITH_WSREP_SR_SPEEDUP + enum sr_state sr_state_; +#endif /* WITH_WSREP_SR_SPEEDUP */ }; static inline const char* to_c_string(enum wsrep::transaction::state state) diff --git a/src/server_state.cpp b/src/server_state.cpp index 9cecf17..7f4421c 100644 --- a/src/server_state.cpp +++ b/src/server_state.cpp @@ -685,6 +685,9 @@ int wsrep::server_state::start_sst(const std::string& sst_request, state(lock, s_donor); int ret(0); lock.unlock(); +#ifdef DEBUG_SR_SPEEDUP + wsrep::log_info() << __FUNCTION__ << "(" << __LINE__ << ")"; +#endif /* DEBUG_SR_SPEEDUP */ if (server_service_.start_sst(sst_request, gtid, bypass)) { lock.lock(); diff --git a/src/transaction.cpp b/src/transaction.cpp index 16bd5eb..0622622 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -132,6 +132,9 @@ int wsrep::transaction::start_transaction( server_id_ = client_state_.server_state().id(); id_ = id; state_ = s_executing; +#ifdef WITH_WSREP_SR_SPEEDUP + sr_state_ = sr_state_none; +#endif /* WITH_WSREP_SR_SPEEDUP */ state_hist_.clear(); ws_handle_ = wsrep::ws_handle(id); flags(wsrep::provider::flag::start_transaction); @@ -1764,8 +1767,14 @@ int wsrep::transaction::certify_fragment( flags(flags() & ~wsrep::provider::flag::start_transaction); } #ifdef DEBUG_SR_SPEEDUP - wsrep::log_info() << "END certify_fragment"; + wsrep::log_info() << "END certify_fragment: " + << "wsrep_get_current_thd() = " + << wsrep_get_current_thd() + << ", sr_state = " << (int)sr_state(); #endif /* DEBUG_SR_SPEEDUP */ +#ifdef WITH_WSREP_SR_SPEEDUP + require_sr_xid(); +#endif /* WITH_WSREP_SR_SPEEDUP */ return ret; }