summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNirbhay Choubey <nirbhay@mariadb.com>2015-12-16 20:07:12 -0500
committerNirbhay Choubey <nirbhay@mariadb.com>2015-12-16 20:07:12 -0500
commit3f515a09ff13d5ee242de121b0162dd4b39db219 (patch)
treef7df6b3e56154aa7b66c3940dc413f158a8b12f0
parentca07ee85ea28d4b820498535508c6b23f089c22c (diff)
downloadmariadb-git-3f515a09ff13d5ee242de121b0162dd4b39db219.tar.gz
MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353
As a fix for MDEV-8208, for initial wsrep threads, the invocation of init_for_queries() was moved after plugins were initialized. Due to which, OPTION_BEGIN bit of wsrep applier THD (originally set in wsrep_replication_process) got reset due to implicit commit within init_for_queries(). As a result, events from a multi-statement transaction from another node were committed separately by the applier thread, which leads to an assertion as they all carry same seqno. Fixed by making sure that variable.option_bits are restored post init_for_queries(). Also restored server_status. Added a test case.
-rw-r--r--mysql-test/suite/galera/r/mdev_9290.result14
-rw-r--r--mysql-test/suite/galera/t/mdev_9290.test24
-rw-r--r--sql/mysqld.cc12
3 files changed, 49 insertions, 1 deletions
diff --git a/mysql-test/suite/galera/r/mdev_9290.result b/mysql-test/suite/galera/r/mdev_9290.result
new file mode 100644
index 00000000000..cb2f0813333
--- /dev/null
+++ b/mysql-test/suite/galera/r/mdev_9290.result
@@ -0,0 +1,14 @@
+#
+# MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353
+# InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno
+#
+CREATE TABLE t1 (i INT) ENGINE=InnoDB;
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+COMMIT;
+SELECT * FROM t1;
+i
+1
+2
+DROP TABLE t1;
diff --git a/mysql-test/suite/galera/t/mdev_9290.test b/mysql-test/suite/galera/t/mdev_9290.test
new file mode 100644
index 00000000000..39e02011a09
--- /dev/null
+++ b/mysql-test/suite/galera/t/mdev_9290.test
@@ -0,0 +1,24 @@
+--source include/galera_cluster.inc
+--source include/have_innodb.inc
+
+--echo #
+--echo # MDEV-9290 : InnoDB: Assertion failure in file trx0sys.cc line 353
+--echo # InnoDB: Failing assertion: xid_seqno > trx_sys_cur_xid_seqno
+--echo #
+
+--connection node_1
+CREATE TABLE t1 (i INT) ENGINE=InnoDB;
+
+--connection node_2
+# Note: a multi-statement transaction should always be the "first" one to execute
+# on this node.
+START TRANSACTION;
+INSERT INTO t1 VALUES (1);
+INSERT INTO t1 VALUES (2);
+COMMIT;
+
+--connection node_1
+SELECT * FROM t1;
+DROP TABLE t1;
+
+--source include/galera_end.inc
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index a5fb510006e..fe74a82a4c6 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4617,10 +4617,20 @@ a file name for --log-bin-index option", opt_binlog_index_name);
THD *current_thd_saved= current_thd;
my_pthread_setspecific_ptr(THR_THD, tmp);
+ /*
+ Also save/restore server_status and variables.option_bits and they
+ get altered during init_for_queries().
+ */
+ unsigned int server_status_saved= tmp->server_status;
+ ulonglong option_bits_saved= tmp->variables.option_bits;
+
tmp->init_for_queries();
/* Restore current_thd. */
my_pthread_setspecific_ptr(THR_THD, current_thd_saved);
+
+ tmp->server_status= server_status_saved;
+ tmp->variables.option_bits= option_bits_saved;
}
}
mysql_mutex_unlock(&LOCK_thread_count);
@@ -4984,7 +4994,7 @@ error:
WSREP_ERROR("Failed to create/initialize system thread");
/* Abort if its the first applier/rollbacker thread. */
- if (wsrep_creating_startup_threads < 2)
+ if (wsrep_creating_startup_threads == 1)
unireg_abort(1);
else
return NULL;