Debian Codegraph @

mysql-test/suite/rpl/t/rpl_inconsistent_error.test

raw
1 #
2 # === Purpose ===
3 # This test script verifies that in a replication environment,
4 # when we have different errors on master and slave side, and if
5 # we have ER_INCONSISTENT_ERROR specified in the replica_skip_errors
6 # list the replication should not stop with error ER_INCONSISTENT_ERROR.
7 #
8 # === Implementation ===
9 #1. Create a table using MyISAM storage engine.
10 #
11 #2. Insert a row with binary logging off, this is done to be able to
12 # generate error in the next query while trying to store a duplicate
13 # value in a column which accepts only unique value.
14 #
15 #3. As the bin logging was off for the first transaction the slave will only
16 # apply the second insert statement (the one which caused error on master).
17 # And should have thrown 'ER_INCONSISTENT_ERROR' error as the expected
18 # error(ER_DUP_ENTRY) is different from the actual error(No error).
19 #
20 #4. Now as we have passed ER_INCONSISTENT_ERROR to --replica-skip-errors in the
21 # .opt file the slave will not throw any error and the replication should
22 # continue.
23 #
24 #5. Test if replication is working fine by taking diff of tables on master
25 # and slave.
26 # === Related bugs and worklogs ===
27 #
28 # Bug#24753281: REQUEST FOR REPLICA_SKIP_ERRORS = ER_INCONSISTENT_ERROR
29
30 --source include/have_binlog_format_statement.inc
31 --source include/force_myisam_default.inc
32 --source include/have_myisam.inc
33 --source include/master-slave.inc
34
35 call mtr.add_suppression("Query caused different errors on source and replica."
36 " Error on master:");
37 # We have to use only MyISAM storage engine and not InnDB here, because using
38 # MyISAM will ensure that the second insert statement is written to binary log
39 # with the error, whereas using InnoDB the insert will just throw
40 # error(ER_DUP_ENTRY) and it won't be written to binary log.
41 CREATE TABLE t1(s INT, UNIQUE(s)) ENGINE=MyISAM;
42
43 SET SESSION sql_log_bin= 0;
44 INSERT INTO t1 VALUES(10);
45 SET SESSION sql_log_bin= 1;
46
47 # We are inserting duplicate value for a column which only accepts unique value.
48 # On MyISAM we will log this statement along with the error it is throwing.
49 --error ER_DUP_ENTRY
50 INSERT INTO t1 VALUES (5),(10);
51 DROP TABLE t1;
52
53 CREATE TABLE t2(s INT);
54 INSERT INTO t2 VALUES(10);
55
56 --source include/sync_slave_sql_with_master.inc
57
58 # Show that replication is working fine.
59 --let $diff_tables=master:t2,slave:t2
60 --source include/diff_tables.inc
61
62 --source include/rpl_connection_master.inc
63 DROP TABLE t2;
64
65 --source include/sync_slave_sql_with_master.inc
66 --source include/stop_slave.inc
67 RESET SLAVE;
68 --let $rpl_only_running_threads= 1
69
70 --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
71 --let $assert_count= 1
72 --let $assert_select= actual error and expected error on replica are different .* The expected error was .* 1062. The actual error .*
73
74 --let $assert_text= Found the expected information about the ER_INCONSISTENT_ERROR being skipped.
75 --source include/assert_grep.inc
76 --source include/rpl_end.inc