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; }