Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_gtid_purged_fail_to_connect.test

raw
1 # ==== Purpose ====
2 #
3 # Test that the slave fails to connect to the master with
4 # MASTER_AUTO_POSITION=1 if the slave is missing some transactions
5 # that the master has purged.
6 #
7 # ==== Implementation ====
8 #
9 # 1) Create a master-slave setup.
10 # 2) Create a table on master, sync it, stop the slave threads and dump thread
11 # on master.
12 # 3) On master, generate a transaction, flush the binary log and execute PURGE
13 # BINARY LOGS TO command so that only remaining binlog only contains
14 # transaction UUID:3.
15 # 4) Verify that the slave fails if it tries to connect using CHANGE MASTER TO
16 # MASTER_AUTO_POSITION=1.
17 # 5) Verify that appropriate messages are logged into master's and slave's
18 # error log.
19 # 6) Verify that replication succeeds if it tries to connect using CHANGE
20 # MASTER TO MASTER_LOG_POS.
21 # 7) Cleanup.
22 #
23 # ==== References ====
24 #
25 # WL#3584 - Global Transaction Identifiers
26 # Bug#29769293 - ERROR 1236 "MASTER HAS PURGED BINARY LOGS CONTAINING GTIDS":
27 # GTID NOT LOGGED
28
29 --source include/not_group_replication_plugin.inc
30 --source include/not_rpl_gtid_only.inc
31 --source include/have_debug.inc
32 --let $rpl_gtid_utils= 1
33
34 --echo #
35 --echo # 1) Create a master-slave setup.
36 --echo #
37 --source include/master-slave.inc
38
39 --let $master_uuid= `SELECT @@SERVER_UUID`
40
41 --echo #
42 --echo # 2) Create a table on master, sync it, stop the slave threads and dump
43 --echo # thread on master.
44 --echo #
45 CREATE TABLE t1 (a INT) ENGINE = InnoDB;
46 --source include/sync_slave_sql_with_master.inc
47 --source include/stop_slave.inc
48
49 --source include/rpl_connection_master.inc
50 # Need to kill the dump thread explicitly: stop slave does not do
51 # that, and if the dump thread is slow, it will still be reading from
52 # the old binlog at the time we do PURGE BINARY LOGS below. That would
53 # prevent PURGE BINARY LOGS from purging the log.
54 --source include/stop_dump_threads.inc
55
56 --echo #
57 --echo # 3) On master, generate a transaction, flush the binary log and execute
58 --echo # PURGE BINARY LOGS TO command so that only remaining binlog only contains
59 --echo # transaction UUID:3.
60 --echo #
61 INSERT INTO t1 VALUES (1);
62
63 FLUSH LOGS;
64 --let $master_file= query_get_value(SHOW MASTER STATUS, File, 1)
65 --let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
66 INSERT INTO t1 VALUES (2);
67 --save_master_pos
68
69 --eval PURGE BINARY LOGS TO '$master_file'
70
71 --let $assert_cond= "[SHOW MASTER STATUS, File, 1]" = "$master_file"
72 --let $assert_text= PURGE BINARY LOGS successfully removed all but the latest file
73 --source include/assert.inc
74
75 --echo #
76 --echo # 4) Verify that the slave fails if it tries to connect using CHANGE
77 --echo # MASTER TO MASTER_AUTO_POSITION=1.
78 --echo #
79 --source include/rpl_connection_slave.inc
80 CHANGE REPLICATION SOURCE TO SOURCE_AUTO_POSITION = 1;
81
82 START SLAVE;
83
84 # BUG#13727933 causes this test to fail sporadically on the following line
85 # apparently the binlog is not always purged on the master (?)
86 --let $slave_io_errno= 13114 # ER_SOURCE_FATAL_ERROR_READING_BINLOG
87 --source include/wait_for_slave_io_error.inc
88 --source include/stop_slave_sql.inc
89
90 # Testing with long set of gtids
91 --source include/rpl_connection_master.inc
92 SET @saved_debug= @@GLOBAL.DEBUG;
93 SET GLOBAL DEBUG= '+d,simulate_long_missing_gtids';
94 --source include/rpl_connection_slave.inc
95 START SLAVE;
96
97 --let $slave_io_errno= 13114 # ER_SOURCE_FATAL_ERROR_READING_BINLOG
98 --source include/wait_for_slave_io_error.inc
99 --source include/stop_slave_sql.inc
100 --source include/rpl_connection_master.inc
101 SET GLOBAL DEBUG= @saved_debug;
102 --source include/rpl_connection_slave.inc
103
104 --echo #
105 --echo # 5) Verify that appropriate messages are logged into master's and slave's
106 --echo # error log.
107 --echo #
108
109 # Verify that an error about long gtids are logged into the slave's error log.
110 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
111 --let $assert_match= .*The GTID sets and the missing purged transactions are too long to print in this message.*
112 --let $assert_select= The GTID sets and the missing purged transactions are too long to print in this message.
113 --let $assert_text= Found a message about the long GTIDs in the slave error log.
114 --source include/assert_grep.inc
115
116 --echo #
117 --echo # 6) Verify that replication succeeds if it tries to connect using CHANGE
118 --echo # MASTER TO MASTER_LOG_POS.
119 --echo #
120 --replace_result $master_file MASTER_FILE $master_pos MASTER_POS
121 eval CHANGE REPLICATION SOURCE TO SOURCE_LOG_FILE = '$master_file', SOURCE_LOG_POS = $master_pos, SOURCE_AUTO_POSITION = 0;
122
123 --source include/start_slave.inc
124 --sync_with_master
125
126 --let $assert_text= t1 should contain only one row with the value 2
127 --let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "1" AND "[SELECT * FROM t1]" = "2"
128 --source include/assert.inc
129 --source include/stop_slave.inc
130
131 # Verify that warning about the missing transactions are logged into the master's error log.
132 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.err
133 --let $assert_match= .*Cannot replicate to server with server_uuid.*The missing transactions are '.*:2'.*
134 --let $assert_select= Cannot replicate to server with server_uuid
135 --let $assert_text= Found warning containing lost GTIDs in the master error log.
136 --source include/assert_grep.inc
137
138 # Verify that an error about the missing transactions are logged into the slave's error log.
139 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
140 --let $assert_match= .*Replicate the missing transactions from elsewhere, or provision a new replica from backup.*the missing transactions are '.*:2'.*
141 --let $assert_select= Replicate the missing transactions from elsewhere, or provision a new replica from backup
142 --let $assert_text= Found warning containing lost GTIDs in the slave error log.
143 --source include/assert_grep.inc
144
145 # Suppress the error on master.
146 --source include/rpl_connection_master.inc
147 CALL mtr.add_suppression("Cannot replicate to server.*server has purged required binary logs.*");
148
149 # Suppress the error on slave.
150 --source include/rpl_connection_slave.inc
151 CALL mtr.add_suppression("Got fatal error 1236 from source.*Replicate the missing transactions from elsewhere");
152
153 --echo #
154 --echo # 7) Cleanup.
155 --echo #
156 --source include/rpl_connection_slave.inc
157 RESET MASTER;
158 RESET SLAVE;
159 --source include/rpl_connection_master.inc
160 RESET MASTER;
161 --source include/rpl_connection_slave.inc
162 --source include/start_slave.inc
163 --source include/rpl_connection_master.inc
164 DROP TABLE t1;
165 --source include/sync_slave_sql_with_master.inc
166 --source include/rpl_end.inc