|
7 | 7 | # ==== Implementation ====
|
8 | 8 | #
|
9 | 9 | # With default setup:
|
10 |
| -# 1) Add a replication filter to the slave node |
11 |
| -# 2) Create a table that gets filtered out by the added filter |
| 10 | +# 1) Create a table that gets filtered out by the added filter |
| 11 | +# 2) Add a replication filter to the slave node |
12 | 12 | # 3) Start an XA transaction and execute a statement that is filtered out by
|
13 | 13 | # replication filter
|
14 | 14 | # 4) Ensure that the error message get logged to the slave error log file.
|
|
20 | 20 | --source include/have_binlog_format_row.inc
|
21 | 21 | --source include/master-slave.inc
|
22 | 22 |
|
23 |
| ---echo # |
24 |
| ---echo # 1) Add a replication filter to the slave node |
25 |
| ---echo # |
26 |
| ---source include/rpl_connection_slave.inc |
| 23 | +--let $gtid_mode_value= `SELECT @@GLOBAL.GTID_MODE = "ON"` |
| 24 | + |
| 25 | +--source include/rpl_connection_master.inc |
| 26 | +# |
| 27 | +# 1) Create a table that gets filtered out by the added filter |
| 28 | +# |
| 29 | +CREATE TABLE t1 (a INT); |
| 30 | +--source include/sync_slave_sql_with_master.inc |
| 31 | + |
| 32 | +# |
| 33 | +# 2) Add a replication filter to the slave node |
| 34 | +# |
27 | 35 | --source include/stop_slave_sql.inc
|
28 |
| -CALL mtr.add_suppression("Slave SQL.*The use of replication filters with XA transactions is not supported, and can lead to an undefined state in the replication slave.*"); |
29 |
| -CHANGE REPLICATION FILTER Replicate_Do_Table=(test.tab1); |
| 36 | +CALL mtr.add_suppression(".*The slave coordinator and worker threads are stopped, possibly leaving data in inconsistent state.*"); |
| 37 | +CALL mtr.add_suppression(".*The use of replication filters with XA transactions is not supported, and can lead to an undefined state in the replication slave.*"); |
| 38 | +CHANGE REPLICATION FILTER Replicate_Ignore_Table=(test.t1); |
30 | 39 | --source include/start_slave_sql.inc
|
31 | 40 |
|
| 41 | +# |
| 42 | +# 3) Start an XA transaction and execute a statement that is filtered out by |
| 43 | +# replication filter |
| 44 | +# |
32 | 45 | --source include/rpl_connection_master.inc
|
33 |
| ---echo # |
34 |
| ---echo # 2) Create a table that gets filtered out by the added filter |
35 |
| ---echo # |
36 |
| -CREATE TABLE t1 (a INT); |
37 |
| ---echo # |
38 |
| ---echo # 3) Start an XA transaction and execute a statement that is filtered out by |
39 |
| ---echo # replication filter |
40 |
| ---echo # |
41 | 46 | XA START '1'; INSERT INTO t1 VALUES (1); XA END '1'; XA PREPARE '1';
|
42 | 47 | XA COMMIT '1';
|
| 48 | +--let $gtid_executed_master= `SELECT @@GLOBAL.GTID_EXECUTED` |
43 | 49 |
|
| 50 | +# |
| 51 | +# Wait for the ER_XA_REPLICATION_FILTERS error to be thrown |
| 52 | +# |
| 53 | +--source include/rpl_connection_slave.inc |
| 54 | +--let $slave_sql_errno= convert_error(ER_XA_REPLICATION_FILTERS) |
| 55 | +--source include/wait_for_slave_sql_error.inc |
| 56 | + |
| 57 | +# |
| 58 | +# Retry the transaction |
| 59 | +# |
| 60 | +START SLAVE SQL_THREAD; |
| 61 | +--let $slave_sql_errno= convert_error(ER_XA_REPLICATION_FILTERS) |
| 62 | +--source include/wait_for_slave_sql_error.inc |
| 63 | + |
| 64 | +# |
| 65 | +# If GTID_MODE is ON, test that are missing GTID |
| 66 | +# |
| 67 | +if ($gtid_mode_value == 1) |
| 68 | +{ |
| 69 | + --let $gtid_executed_slave= `SELECT @@GLOBAL.GTID_EXECUTED` |
| 70 | + --let $gtid_missing_slave= `SELECT GTID_SUBTRACT('$gtid_executed_master', '$gtid_executed_slave')` |
| 71 | + --disable_result_log |
| 72 | + --let $include_silent= 1 |
| 73 | + --let $assert_text= slave has missing GTIDs |
| 74 | + --let $assert_cond= "$gtid_missing_slave" != "" |
| 75 | + --source include/assert.inc |
| 76 | + --let $include_silent= |
| 77 | + --enable_result_log |
| 78 | +} |
| 79 | + |
| 80 | +# |
| 81 | +# Ensure that the transaction didn't get logged into the binary log |
| 82 | +# |
| 83 | +--let $event_sequence= Gtid/SET.* # Query/use.* # Gtid/SET.* # Query/XA START.* # Table_map/.* # Write_rows/.* # Query/XA END.* # XA_prepare/XA PREPARE.* # Gtid/SET.* # Query/XA COMMIT.* |
| 84 | +--let $invert= 1 |
| 85 | +--source include/assert_binlog_events.inc |
| 86 | + |
| 87 | +# |
| 88 | +# Clear replication filters in order for the transaction to succeed. |
| 89 | +# |
| 90 | +CHANGE REPLICATION FILTER Replicate_Ignore_Table=(); |
| 91 | +--let $slave_sql_errno= |
| 92 | +--source include/start_slave_sql.inc |
| 93 | +--source include/rpl_connection_master.inc |
44 | 94 | --source include/sync_slave_sql_with_master.inc
|
| 95 | +--let $count = `SELECT COUNT(1) FROM test.t1;` |
| 96 | +--let $assert_text = table 'test.t1' record count must be 1 |
| 97 | +--let $assert_cond = $count = 1 |
| 98 | +--source include/assert.inc |
45 | 99 |
|
46 |
| ---echo # |
47 |
| ---echo # 4) Ensure that the error message get logged to the slave error log file. |
48 |
| ---echo # |
| 100 | +# |
| 101 | +# 4) Ensure that the error message get logged to the slave error log file. |
| 102 | +# |
49 | 103 | --let $assert_file= $MYSQLTEST_VARDIR/log/mysqld.2.err
|
50 |
| ---let $assert_only_after= CURRENT_TEST: rpl_gtid:rpl_xa_with_filters_error_msg |
| 104 | +--let $assert_only_after= CURRENT_TEST: rpl:rpl_xa_with_filters_error_msg |
51 | 105 | --let $assert_match= The use of replication filters with XA transactions is not supported, and can lead to an undefined state in the replication slave
|
52 | 106 | --let $assert_select= Slave SQL
|
53 | 107 | --let $assert_text= Found error message regarding usage of replication filters with XA transactions
|
54 | 108 | --source include/assert_grep.inc
|
55 | 109 |
|
56 | 110 | --source include/rpl_connection_master.inc
|
57 | 111 | DROP TABLE t1;
|
58 |
| ---source include/sync_slave_sql_with_master.inc |
59 |
| - |
60 |
| ---let $slave_sql_errno= convert_error(ER_XA_REPLICATION_FILTERS) |
61 |
| - |
62 |
| ---source include/stop_slave_sql.inc |
63 |
| -CHANGE REPLICATION FILTER Replicate_Do_Table=(); |
64 |
| ---source include/start_slave_sql.inc |
65 | 112 |
|
66 | 113 | --source include/rpl_end.inc
|
0 commit comments