diff options
author | Andrei <andrei.elkin@mariadb.com> | 2021-12-26 18:13:49 +0200 |
---|---|---|
committer | Andrei <andrei.elkin@mariadb.com> | 2022-01-14 11:43:51 +0200 |
commit | 37b789d97bb07ed290fc9f39cbf01e0cdcd7d937 (patch) | |
tree | 7bc125856f1f96894dc7ebcba34e9d9c791f60be | |
parent | 9fcb5c5d2fa21babd1d890cd3750c56d28870396 (diff) | |
download | mariadb-git-37b789d97bb07ed290fc9f39cbf01e0cdcd7d937.tar.gz |
MDEV-27365 CREATE-or-REPLACE SEQUENCE is binlogged without DDL flag
CREATE-OR-REPLACE SEQUENCE is not logged with Gtid event DDL flag
which affects its slave parallel execution.
Unlike other DDL:s it can occur in concurrent execution with following transactions
which can lead to various errors, including asserts like
(mdl_request->type != MDL_INTENTION_EXCLUSIVE && mdl_request->type != MDL_EXCLUSIVE) || !(get_thd()->rgi_slave && get_thd()->rgi_slave->is_parallel_exec && lock->check_if_conflicting_replication_locks(this)
in MDL_context::acquire_lock.
Fixed to wrap internal statement level commit with save-
and-restore of TRANS_THD::m_unsafe_rollback_flags.
-rw-r--r-- | mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result | 8 | ||||
-rw-r--r-- | mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test | 30 | ||||
-rw-r--r-- | sql/sql_sequence.cc | 11 |
3 files changed, 46 insertions, 3 deletions
diff --git a/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result b/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result new file mode 100644 index 00000000000..34d8bbf5999 --- /dev/null +++ b/mysql-test/suite/binlog/r/binlog_parallel_replication_ddl.result @@ -0,0 +1,8 @@ +RESET MASTER; +CREATE OR REPLACE SEQUENCE s1; +DROP SEQUENCE s1; +FLUSH LOGS; +FOUND 2 /GTID [0-9]+-[0-9]+-[0-9]+/ in mysqlbinlog.sql +The same as above number of samples must be found: +FOUND 2 /GTID [0-9]+-[0-9]+-[0-9]+ ddl/ in mysqlbinlog.sql +End of the tests diff --git a/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test b/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test new file mode 100644 index 00000000000..d861ecc96df --- /dev/null +++ b/mysql-test/suite/binlog/t/binlog_parallel_replication_ddl.test @@ -0,0 +1,30 @@ +# Check binlog properties of various DDL:s. +# Motivated by MDEV-27365. +# +--source include/have_log_bin.inc +--source include/have_binlog_format_mixed.inc + +RESET MASTER; + +# MDEV-27365 CREATE-or-REPLACE SEQUENCE bilogged without DDL flag +# Prove it is logged with the DDL flag. +CREATE OR REPLACE SEQUENCE s1; + +# This one has been always correct. +DROP SEQUENCE s1; +FLUSH LOGS; + +--let $MYSQLD_DATADIR= `select @@datadir` +--exec $MYSQL_BINLOG --base64-output=decode-rows $MYSQLD_DATADIR/master-bin.000001 > $MYSQLTEST_VARDIR/tmp/mysqlbinlog.sql + +--let SEARCH_PATTERN= GTID [0-9]+-[0-9]+-[0-9]+ +--let SEARCH_FILE= $MYSQLTEST_VARDIR/tmp/mysqlbinlog.sql +--source include/search_pattern_in_file.inc + +--echo The same as above number of samples must be found: +--let SEARCH_PATTERN= GTID [0-9]+-[0-9]+-[0-9]+ ddl +--let SEARCH_FILE= $MYSQLTEST_VARDIR/tmp/mysqlbinlog.sql +--source include/search_pattern_in_file.inc +--remove_file $MYSQLTEST_VARDIR/tmp/mysqlbinlog.sql + +--echo End of the tests diff --git a/sql/sql_sequence.cc b/sql/sql_sequence.cc index 307a0b29c57..b32f1294bec 100644 --- a/sql/sql_sequence.cc +++ b/sql/sql_sequence.cc @@ -365,9 +365,14 @@ bool sequence_insert(THD *thd, LEX *lex, TABLE_LIST *org_table_list) seq->reserved_until= seq->start; error= seq->write_initial_sequence(table); - - if (trans_commit_stmt(thd)) - error= 1; + { + uint save_unsafe_rollback_flags= + thd->transaction->stmt.m_unsafe_rollback_flags; + if (trans_commit_stmt(thd)) + error= 1; + thd->transaction->stmt.m_unsafe_rollback_flags= + save_unsafe_rollback_flags; + } if (trans_commit_implicit(thd)) error= 1; |