summaryrefslogtreecommitdiff
path: root/sql/wsrep_mysqld.cc
diff options
context:
space:
mode:
authorseppo <seppo.jaakola@iki.fi>2020-03-24 11:01:42 +0200
committerGitHub <noreply@github.com>2020-03-24 11:01:42 +0200
commit5918b17004674f425f2cd1d4f0bac29b3bcecb35 (patch)
treefd5be51c5b8d516aaa51c9fa1be1bab1e6b2ab1a /sql/wsrep_mysqld.cc
parenta7cbce06d432cbcb88e071731089aacfd41750fd (diff)
downloadmariadb-git-5918b17004674f425f2cd1d4f0bac29b3bcecb35.tar.gz
MDEV-21473 conflicts with async slave BF aborting (#1475)
If async slave thread (slave SQL handler), becomes a BF victim, it may occasionally happen that rollbacker thread is used to carry out the rollback instead of the async slave thread. This can happen, if async slave thread has flagged "idle" state when BF thread tries to figure out how to kill the victim. The issue was possible to test by using a galera cluster as slave for external master, and issuing high load of conflicting writes through async replication and directly against galera cluster nodes. However, a deterministic mtr test for the "conflict window" has not yet been worked on. The fix, in this patch makes sure that async slave thread state is never set to IDLE. This prevents the rollbacker thread to intervene. The wsrep_query_state change was refactored to happen by dedicated function to make controlling the idle state change in one place.
Diffstat (limited to 'sql/wsrep_mysqld.cc')
-rw-r--r--sql/wsrep_mysqld.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/sql/wsrep_mysqld.cc b/sql/wsrep_mysqld.cc
index ba6c2d24f77..a2666591660 100644
--- a/sql/wsrep_mysqld.cc
+++ b/sql/wsrep_mysqld.cc
@@ -2586,6 +2586,17 @@ extern "C" void wsrep_thd_set_exec_mode(THD *thd, enum wsrep_exec_mode mode)
extern "C" void wsrep_thd_set_query_state(
THD *thd, enum wsrep_query_state state)
{
+ /* async slave thread should never flag IDLE state, as it may
+ give rollbacker thread chance to interfere and rollback async slave
+ transaction.
+ in fact, async slave thread is never idle as it reads complete
+ transactions from relay log and applies them, as a whole.
+ BF abort happens voluntarily by async slave thread.
+ */
+ if (thd->slave_thread && state == QUERY_IDLE) {
+ WSREP_DEBUG("Skipping IDLE state change for slave SQL");
+ return;
+ }
thd->wsrep_query_state= state;
}