From f8a20ff00f28583b1d257cc148d8ab705dd274ce Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Wed, 5 Apr 2023 09:30:55 +0300 Subject: [PATCH] Make is_rollbacker_active() public, don't unlock for background rollback Make is_rollbacker_active() public so that the BF thread can check if the rollbacker was started or not. Also don't unlock the lock for launching the background rollbacker to avoid race conditions in accessing the victim state. --- include/wsrep/client_state.hpp | 14 +++++++++----- src/transaction.cpp | 2 -- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/wsrep/client_state.hpp b/include/wsrep/client_state.hpp index 8c62d0b..d8449d7 100644 --- a/include/wsrep/client_state.hpp +++ b/include/wsrep/client_state.hpp @@ -902,6 +902,15 @@ namespace wsrep { return current_error_status_; } + + /** + * Return true if rollbacker is active. The caller should + * hold the mutex protecting client_state. + */ + bool is_rollbacker_active() + { + return rollbacker_active_; + } protected: /** * Client context constuctor. This is protected so that it @@ -1007,11 +1016,6 @@ namespace wsrep { rollbacker_active_ = value; } - - bool is_rollbacker_active() - { - return rollbacker_active_; - } }; static inline const char* to_c_string( diff --git a/src/transaction.cpp b/src/transaction.cpp index c864a0f..3860666 100644 --- a/src/transaction.cpp +++ b/src/transaction.cpp @@ -1073,9 +1073,7 @@ bool wsrep::transaction::bf_abort( } } - lock.unlock(); server_service_.background_rollback(client_state_); - lock.lock(); } } return ret;