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

@ -37,6 +37,7 @@ void wsrep::client_state::open(wsrep::client_id id)
debug_log_state("open: enter");
owning_thread_id_ = wsrep::this_thread::get_id();
current_thread_id_ = owning_thread_id_;
has_rollbacker_ = false;
state(lock, s_idle);
id_ = id;
debug_log_state("open: leave");
@ -86,7 +87,10 @@ int wsrep::client_state::before_command()
if (transaction_.active() &&
server_state_.rollback_mode() == wsrep::server_state::rm_sync)
{
while (transaction_.state() == wsrep::transaction::s_aborting)
/*
* has_rollbacker() returns false, when background rollback is over
*/
while (has_rollbacker())
{
cond_.wait(lock);
}

View File

@ -918,6 +918,8 @@ bool wsrep::transaction::bf_abort(
// between releasing the lock and before background
// rollbacker gets control.
state(lock, wsrep::transaction::s_aborting);
client_state_.set_rollbacker(true);
if (client_state_.mode() == wsrep::client_state::m_high_priority)
{
lock.unlock();