From 386ac12a48c7a4abcd2f82f21bcf5a48a235d7fd Mon Sep 17 00:00:00 2001 From: mkaruza Date: Mon, 26 Jul 2021 09:14:37 +0200 Subject: [PATCH] MDEV-25740 Assertion `!wsrep_has_changes(thd) || (thd->lex->sql_command == SQLCOM_CREATE_TABLE && !thd->is_current_stmt_binlog_format_row())' failed in void wsrep_commit_empty(THD*, bool) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using ROLLBACK with `completion_type = CHAIN` result in start of transaction and implicit commit before previous WSREP internal data is cleared. Reviewed-by: Jan Lindström --- mysql-test/suite/galera/r/MDEV-25740.result | 9 +++++++++ mysql-test/suite/galera/t/MDEV-25740.test | 14 ++++++++++++++ sql/sql_parse.cc | 5 +++++ 3 files changed, 28 insertions(+) create mode 100644 mysql-test/suite/galera/r/MDEV-25740.result create mode 100644 mysql-test/suite/galera/t/MDEV-25740.test diff --git a/mysql-test/suite/galera/r/MDEV-25740.result b/mysql-test/suite/galera/r/MDEV-25740.result new file mode 100644 index 00000000000..5a4318a7f19 --- /dev/null +++ b/mysql-test/suite/galera/r/MDEV-25740.result @@ -0,0 +1,9 @@ +connection node_2; +connection node_1; +SET AUTOCOMMIT = OFF; +SET completion_type = CHAIN; +CREATE TABLE t1(f1 INT) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (1); +ROLLBACK; +DROP TABLE t1; diff --git a/mysql-test/suite/galera/t/MDEV-25740.test b/mysql-test/suite/galera/t/MDEV-25740.test new file mode 100644 index 00000000000..0ea8d5f55c0 --- /dev/null +++ b/mysql-test/suite/galera/t/MDEV-25740.test @@ -0,0 +1,14 @@ +# +# When `completion_type = CHAIN` is used, transaction started should not have previous writeset. +# + +--source include/galera_cluster.inc +--source include/have_innodb.inc + +SET AUTOCOMMIT = OFF; +SET completion_type = CHAIN; +CREATE TABLE t1(f1 INT) ENGINE=InnoDB; +BEGIN; +INSERT INTO t1 VALUES (1); +ROLLBACK; +DROP TABLE t1; diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 3cccca9b786..9e78a1a95e2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -5750,6 +5750,11 @@ mysql_execute_command(THD *thd) /* Begin transaction with the same isolation level. */ if (tx_chain) { +#ifdef WITH_WSREP + /* If there are pending changes after rollback we should clear them */ + if (wsrep_on(thd) && wsrep_has_changes(thd)) + wsrep_after_statement(thd); +#endif if (trans_begin(thd)) goto error; }