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

codership/wsrep-lib#23 before_command() wait for ongoing rollbacks leaks

Storing information that background rollbacker in ongoing in client state has_rollback_
This can be used for detecting if there is ongoing background rollback,
and client should keep waiting in before_command() entry to avoid conflicts
in accessing client state during background rollbacking.

transaction::bf_abort() is modified to set has_rollback_ flag when
backgroung rollbacking has been assigned for the client

sync_rollback_complete() method has been modified to reset the backround
rollbacker flag
This commit is contained in:
sjaakola
2018-11-24 15:14:26 +02:00
parent 31f09ca4aa
commit cfcf34e70f
5 changed files with 29 additions and 3 deletions

View File

@ -428,12 +428,14 @@ namespace wsrep
/**
* This method should be called by the background rollbacker
* thread after the rollback is complete. This will allow
* the client to proceed with command execution.
* the client to proceed through before_command().
*/
void sync_rollback_complete()
{
wsrep::unique_lock<wsrep::mutex> lock(mutex_);
assert(state_ == s_idle && mode_ == m_local &&
transaction_.state() == wsrep::transaction::s_aborted);
set_rollbacker(false);
cond_.notify_all();
}
/** @} */
@ -707,6 +709,7 @@ namespace wsrep
enum mode mode)
: owning_thread_id_(wsrep::this_thread::get_id())
, current_thread_id_(owning_thread_id_)
, has_rollbacker_(false)
, mutex_(mutex)
, cond_(cond)
, server_state_(server_state)
@ -749,6 +752,7 @@ namespace wsrep
wsrep::thread::id owning_thread_id_;
wsrep::thread::id current_thread_id_;
bool has_rollbacker_;
wsrep::mutex& mutex_;
wsrep::condition_variable& cond_;
wsrep::server_state& server_state_;
@ -766,6 +770,21 @@ namespace wsrep
int debug_log_level_;
enum wsrep::client_error current_error_;
enum wsrep::provider::status current_error_status_;
/**
* Assigns external rollbacker thread for the client
* this will block client in before_command(), until
* rolbacker has released the client
*/
void set_rollbacker(bool value)
{
has_rollbacker_ = value;
}
bool has_rollbacker()
{
return(has_rollbacker_);
}
};
static inline const char* to_c_string(