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

Add sr_state_ in wsrep::transaction.

Add debug messages.
This commit is contained in:
Pekka Lampio
2021-07-12 16:23:42 +03:00
parent cad03e903c
commit b5f2db2c9c
4 changed files with 55 additions and 2 deletions

View File

@ -220,7 +220,7 @@ namespace wsrep
#ifdef WITH_WSREP_SR_SPEEDUP #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. * transaction or a NULL pointer if no such cache exists.
*/ */
virtual void *get_binlog_cache() = 0; virtual void *get_binlog_cache() = 0;

View File

@ -145,6 +145,44 @@ namespace wsrep
#ifdef WITH_WSREP_SR_SPEEDUP #ifdef WITH_WSREP_SR_SPEEDUP
int set_fragments_from_table(); int set_fragments_from_table();
void *get_binlog_cache(); 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 */ #endif /* WITH_WSREP_SR_SPEEDUP */
bool pa_unsafe() const { return pa_unsafe_; } bool pa_unsafe() const { return pa_unsafe_; }
@ -277,6 +315,9 @@ namespace wsrep
wsrep::sr_key_set sr_keys_; wsrep::sr_key_set sr_keys_;
wsrep::mutable_buffer apply_error_buf_; wsrep::mutable_buffer apply_error_buf_;
wsrep::xid xid_; 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) static inline const char* to_c_string(enum wsrep::transaction::state state)

View File

@ -685,6 +685,9 @@ int wsrep::server_state::start_sst(const std::string& sst_request,
state(lock, s_donor); state(lock, s_donor);
int ret(0); int ret(0);
lock.unlock(); lock.unlock();
#ifdef DEBUG_SR_SPEEDUP
wsrep::log_info() << __FUNCTION__ << "(" << __LINE__ << ")";
#endif /* DEBUG_SR_SPEEDUP */
if (server_service_.start_sst(sst_request, gtid, bypass)) if (server_service_.start_sst(sst_request, gtid, bypass))
{ {
lock.lock(); lock.lock();

View File

@ -132,6 +132,9 @@ int wsrep::transaction::start_transaction(
server_id_ = client_state_.server_state().id(); server_id_ = client_state_.server_state().id();
id_ = id; id_ = id;
state_ = s_executing; state_ = s_executing;
#ifdef WITH_WSREP_SR_SPEEDUP
sr_state_ = sr_state_none;
#endif /* WITH_WSREP_SR_SPEEDUP */
state_hist_.clear(); state_hist_.clear();
ws_handle_ = wsrep::ws_handle(id); ws_handle_ = wsrep::ws_handle(id);
flags(wsrep::provider::flag::start_transaction); flags(wsrep::provider::flag::start_transaction);
@ -1764,8 +1767,14 @@ int wsrep::transaction::certify_fragment(
flags(flags() & ~wsrep::provider::flag::start_transaction); flags(flags() & ~wsrep::provider::flag::start_transaction);
} }
#ifdef DEBUG_SR_SPEEDUP #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 */ #endif /* DEBUG_SR_SPEEDUP */
#ifdef WITH_WSREP_SR_SPEEDUP
require_sr_xid();
#endif /* WITH_WSREP_SR_SPEEDUP */
return ret; return ret;
} }