| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# This test uses a binlog generated in a 5.7 server with a ER_BAD_TABLE_ERROR to |
| 4 |
# check that the slave issues an error when an atomic DDL was replicated to the |
| 5 |
# slave but was not successfully applied. |
| 6 |
# |
| 7 |
# ==== References ==== |
| 8 |
# |
| 9 |
# BUG#26133488 SLAVE IS DIVERGED FROM MASTER BUT CROSS-VERSION RPL CONTINUES |
| 10 |
# WITHOUT ERROR |
| 11 |
# |
| 12 |
|
| 13 |
# the 5.7 master binlog file was only recorded in statement format |
| 14 |
--source include/have_binlog_format_statement.inc |
| 15 |
--let $rpl_gtid_utils= 1 |
| 16 |
--let $rpl_skip_start_slave= 1 |
| 17 |
--source include/set_privilege_checks_user_as_system_user.inc |
| 18 |
--source include/master-slave.inc |
| 19 |
|
| 20 |
# add suppressions to the slave for expected errors/warnings |
| 21 |
--source include/rpl_connection_slave.inc |
| 22 |
CALL mtr.add_suppression("Unknown table"); |
| 23 |
CALL mtr.add_suppression("A commit for an atomic DDL statement was unsuccessful on the source and the replica"); |
| 24 |
CALL mtr.add_suppression("Query caused different errors on source and replica."); |
| 25 |
CALL mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state."); |
| 26 |
CALL mtr.add_suppression("Replica worker thread has failed to apply an event. As a consequence, the coordinator thread is stopping execution."); |
| 27 |
|
| 28 |
--let $MYSQLD_SLAVE_DATADIR= `select @@datadir` |
| 29 |
|
| 30 |
# clear slave datadir |
| 31 |
RESET SLAVE; |
| 32 |
--remove_file $MYSQLD_SLAVE_DATADIR/slave-relay-bin.000001 |
| 33 |
--remove_file $MYSQLD_SLAVE_DATADIR/slave-relay-bin.index |
| 34 |
|
| 35 |
# copy the binlog with the following statements: |
| 36 |
# --source include/have_binlog_format_statement.inc |
| 37 |
# CREATE TABLE t1 (a INT); |
| 38 |
# --error ER_BAD_TABLE_ERROR |
| 39 |
# DROP TABLE t1, t2; |
| 40 |
|
| 41 |
# on Win* platforms path separator is backslash |
| 42 |
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`) |
| 43 |
{ |
| 44 |
--copy_file std_data/slave-relay-bin_win.index $MYSQLD_SLAVE_DATADIR/slave-relay-bin.index |
| 45 |
} |
| 46 |
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64', 'Windows')`) |
| 47 |
{ |
| 48 |
--copy_file std_data/slave-relay-bin_linux.index $MYSQLD_SLAVE_DATADIR/slave-relay-bin.index |
| 49 |
} |
| 50 |
|
| 51 |
--copy_file std_data/rpl_atomic_ddl_rollback_table.000001 $MYSQLD_SLAVE_DATADIR/slave-relay-bin.000001 |
| 52 |
|
| 53 |
START SLAVE; |
| 54 |
|
| 55 |
--let $slave_sql_errno= convert_error(ER_INCONSISTENT_ERROR) |
| 56 |
--source include/wait_for_slave_sql_error.inc |
| 57 |
|
| 58 |
--source include/stop_slave.inc |
| 59 |
--let $disjoint_value= `SELECT GTID_IS_DISJOINT('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1', @@GLOBAL.GTID_EXECUTED)` |
| 60 |
--let $assert_text= Check that the failed ddl was rollbacked and is not in the slave gtid_executed set |
| 61 |
--let $assert_cond= $disjoint_value = 1 |
| 62 |
--source include/assert.inc |
| 63 |
|
| 64 |
# clean up slave |
| 65 |
RESET SLAVE; |
| 66 |
SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:1'; |
| 67 |
BEGIN; |
| 68 |
COMMIT; |
| 69 |
SET GTID_NEXT= AUTOMATIC; |
| 70 |
--source include/start_slave.inc |
| 71 |
DROP TABLE t1; |
| 72 |
|
| 73 |
|
| 74 |
--source include/stop_slave.inc |
| 75 |
RESET SLAVE; |
| 76 |
--remove_file $MYSQLD_SLAVE_DATADIR/slave-relay-bin.000001 |
| 77 |
--remove_file $MYSQLD_SLAVE_DATADIR/slave-relay-bin.index |
| 78 |
|
| 79 |
# copy the binlog with the following statements: |
| 80 |
# --source include/have_binlog_format_statement.inc |
| 81 |
# CREATE VIEW v1 as SELECT 1; |
| 82 |
# --error ER_BAD_TABLE_ERROR |
| 83 |
# DROP VIEW v1, v2; |
| 84 |
|
| 85 |
# on Win* platforms path separator is backslash |
| 86 |
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) IN ('Win32', 'Win64', 'Windows')`) |
| 87 |
{ |
| 88 |
--copy_file std_data/slave-relay-bin_win.index $MYSQLD_SLAVE_DATADIR/slave-relay-bin.index |
| 89 |
} |
| 90 |
if (`SELECT CONVERT(@@VERSION_COMPILE_OS USING latin1) NOT IN ('Win32', 'Win64', 'Windows')`) |
| 91 |
{ |
| 92 |
--copy_file std_data/slave-relay-bin_linux.index $MYSQLD_SLAVE_DATADIR/slave-relay-bin.index |
| 93 |
} |
| 94 |
|
| 95 |
--copy_file std_data/rpl_atomic_ddl_rollback_view.000001 $MYSQLD_SLAVE_DATADIR/slave-relay-bin.000001 |
| 96 |
|
| 97 |
START SLAVE; |
| 98 |
|
| 99 |
--let $slave_sql_errno= convert_error(ER_INCONSISTENT_ERROR) |
| 100 |
--source include/wait_for_slave_sql_error.inc |
| 101 |
|
| 102 |
--let $disjoint_value= `SELECT GTID_IS_DISJOINT('aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2', @@GLOBAL.GTID_EXECUTED)` |
| 103 |
--let $assert_text= Check that the failed ddl was rollbacked and is not in the slave gtid_executed set |
| 104 |
--let $assert_cond= $disjoint_value = 1 |
| 105 |
--source include/assert.inc |
| 106 |
|
| 107 |
# clean up slave |
| 108 |
--source include/stop_slave.inc |
| 109 |
RESET SLAVE; |
| 110 |
SET GTID_NEXT= 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa:2'; |
| 111 |
BEGIN; |
| 112 |
COMMIT; |
| 113 |
SET GTID_NEXT= AUTOMATIC; |
| 114 |
--source include/start_slave.inc |
| 115 |
DROP VIEW v1; |
| 116 |
|
| 117 |
# check that the error is present twice in the error log, once per not applied |
| 118 |
# atomic ddl |
| 119 |
--let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err |
| 120 |
--let $assert_count= 2 |
| 121 |
--let $assert_select= (Replica:|Worker).*A commit for an atomic DDL statement was unsuccessful on the source and the replica |
| 122 |
--let $assert_text= There shall be an error when the master is 5.7-, the slave is 8.0+, and the latter fails to apply an atomic DDL |
| 123 |
--source include/assert_grep.inc |
| 124 |
|
| 125 |
--source include/rpl_end.inc |