From 1e2a4ed7ed41f3f6900e164dfad38c95d2af8b7b Mon Sep 17 00:00:00 2001 From: Teemu Ollakka Date: Thu, 23 Jul 2020 23:05:47 +0300 Subject: [PATCH] MDEV-21718 Assertion in wsrep::client_state::before_command(). An assertion `server_state_.rollback_mode() == wsrep::server_state::rm_async` fired in before_command() when - thread-handling was set to pool-of-threads and - a BF abort happened between client session calls to wait_rollback_complete_and_acquire_ownership() and before_command(). This commit introduces a test case to reproduce the crash and updates wsrep-lib submodule to fixed version. --- mysql-test/suite/galera/r/mdev_21718.result | 16 ++++++++++ mysql-test/suite/galera/t/mdev_21718.cnf | 4 +++ mysql-test/suite/galera/t/mdev_21718.test | 33 +++++++++++++++++++++ sql/sql_parse.cc | 1 + wsrep-lib | 2 +- 5 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 mysql-test/suite/galera/r/mdev_21718.result create mode 100644 mysql-test/suite/galera/t/mdev_21718.cnf create mode 100644 mysql-test/suite/galera/t/mdev_21718.test diff --git a/mysql-test/suite/galera/r/mdev_21718.result b/mysql-test/suite/galera/r/mdev_21718.result new file mode 100644 index 00000000000..ce938614854 --- /dev/null +++ b/mysql-test/suite/galera/r/mdev_21718.result @@ -0,0 +1,16 @@ +connection node_2; +connection node_1; +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; +connection node_1; +START TRANSACTION; +INSERT INTO t1 VALUES (1); +SET DEBUG_SYNC = "wsrep_before_before_command SIGNAL reached WAIT_FOR continue"; +COMMIT; +connection node_1_ctrl; +SET DEBUG_SYNC = "now WAIT_FOR reached"; +connection node_2; +INSERT INTO t1 VALUES (1); +connection node_1; +ERROR 40001: Deadlock found when trying to get lock; try restarting transaction +DROP TABLE t1; +SET DEBUG_SYNC = "RESET"; diff --git a/mysql-test/suite/galera/t/mdev_21718.cnf b/mysql-test/suite/galera/t/mdev_21718.cnf new file mode 100644 index 00000000000..9e066597a13 --- /dev/null +++ b/mysql-test/suite/galera/t/mdev_21718.cnf @@ -0,0 +1,4 @@ +!include ../galera_2nodes.cnf + +[mysqld] +thread-handling=pool-of-threads diff --git a/mysql-test/suite/galera/t/mdev_21718.test b/mysql-test/suite/galera/t/mdev_21718.test new file mode 100644 index 00000000000..413e9da0e83 --- /dev/null +++ b/mysql-test/suite/galera/t/mdev_21718.test @@ -0,0 +1,33 @@ +# +# MDEV-21718 Reproduce a case where BF abort after +# client session acquires the ownership but before calls +# before_command() causes an assertion in wsrep-lib. +# +--source include/galera_cluster.inc +--source include/have_innodb.inc + +CREATE TABLE t1 (f1 INT PRIMARY KEY) ENGINE=InnoDB; + +--let $galera_connection_name = node_1_ctrl +--let $galera_server_number = 1 +--source include/galera_connect.inc + +--connection node_1 +START TRANSACTION; +INSERT INTO t1 VALUES (1); +SET DEBUG_SYNC = "wsrep_before_before_command SIGNAL reached WAIT_FOR continue"; +--send COMMIT + +--connection node_1_ctrl +SET DEBUG_SYNC = "now WAIT_FOR reached"; + +--connection node_2 +INSERT INTO t1 VALUES (1); + +# BF abort wakes up node_1 from sync wait. +--connection node_1 +--error ER_LOCK_DEADLOCK +--reap + +DROP TABLE t1; +SET DEBUG_SYNC = "RESET"; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 4596915b096..9f7cf514ac3 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -1280,6 +1280,7 @@ bool do_command(THD *thd) command= fetch_command(thd, packet); #ifdef WITH_WSREP + DEBUG_SYNC(thd, "wsrep_before_before_command"); /* Aborted by background rollbacker thread. Handle error here and jump straight to out diff --git a/wsrep-lib b/wsrep-lib index 8ba574f7bf1..3e5a28df32c 160000 --- a/wsrep-lib +++ b/wsrep-lib @@ -1 +1 @@ -Subproject commit 8ba574f7bf19bdc0de18e2225068c5a3f2dcdea4 +Subproject commit 3e5a28df32c85c7768dd84d1731ad4661bf90022