Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_gtid_deleted_binlog_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 that
5 # the user has manually deleted the binary logs that slave requires.
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 delete the
13 # first binary logs so that only remaining binlog only contains transaction
14 # 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 # Bug#29769293 - ERROR 1236 "MASTER HAS PURGED BINARY LOGS CONTAINING GTIDS":
26 # GTID NOT LOGGED
27
28 # This test is binlog format agnostic
29 --source include/have_binlog_format_row.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 delete
58 --echo # the first binary logs so that only remaining binlog only contains
59 --echo # transaction UUID:3.
60 --echo #
61 INSERT INTO t1 VALUES (1);
62
63 --let $master_file_old= query_get_value(SHOW MASTER STATUS, File, 1)
64 FLUSH LOGS;
65
66 --let $master_file= query_get_value(SHOW MASTER STATUS, File, 1)
67 --let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
68 INSERT INTO t1 VALUES (2);
69 --save_master_pos
70
71 # Remove the binary log manually
72 --let $MASTER_DATADIR= `select @@datadir`
73 --remove_file $MASTER_DATADIR/$master_file_old
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 --let $slave_io_errno= 13114 # ER_SOURCE_FATAL_ERROR_READING_BINLOG
85 --source include/wait_for_slave_io_error.inc
86 --source include/stop_slave_sql.inc
87
88 --echo #
89 --echo # 5) Verify that appropriate messages are logged into master's and slave's
90 --echo # error log.
91 --echo #
92
93 # Verify that warning about the missing transactions are logged into the master's error log.
94 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.err
95 --let $assert_match= .*Cannot replicate to server with server_uuid.*The missing transactions are '.*:1'.*
96 --let $assert_select= Cannot replicate to server with server_uuid
97 --let $assert_text= Found warning containing lost GTIDs in the master error log.
98 --source include/assert_grep.inc
99
100 # Verify that an error about the missing transactions are logged into the slave's error log.
101 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
102 --let $assert_match= .*Replicate the missing transactions from elsewhere, or provision a new replica from backup.*the missing transactions are '.*:1'.*
103 --let $assert_select= Replicate the missing transactions from elsewhere, or provision a new replica from backup
104 --let $assert_text= Found warning containing lost GTIDs in the slave error log.
105 --source include/assert_grep.inc
106
107 --echo #
108 --echo # 6) Verify that replication succeeds if it tries to connect using CHANGE
109 --echo # MASTER TO MASTER_LOG_POS.
110 --echo #
111 --replace_result $master_file MASTER_FILE $master_pos MASTER_POS
112 --eval CHANGE REPLICATION SOURCE TO SOURCE_LOG_FILE = '$master_file', SOURCE_LOG_POS = $master_pos, SOURCE_AUTO_POSITION = 0
113
114 --source include/start_slave.inc
115 --sync_with_master
116
117 --let $assert_text= t1 should contain only one row with the value 2
118 --let $assert_cond= "[SELECT COUNT(*) FROM t1]" = "1" AND "[SELECT * FROM t1]" = "2"
119 --source include/assert.inc
120 --source include/stop_slave.inc
121
122 # Suppress the error on master.
123 --source include/rpl_connection_master.inc
124 CALL mtr.add_suppression("Cannot replicate to server.*server has purged required binary logs.*");
125 CALL mtr.add_suppression("Failed to open log");
126 CALL mtr.add_suppression("Could not open log");
127
128 # Suppress the error on slave.
129 --source include/rpl_connection_slave.inc
130 CALL mtr.add_suppression("Got fatal error 1236 from source.*Replicate the missing transactions from elsewhere");
131
132 --echo #
133 --echo # 7) Cleanup.
134 --echo #
135 --disable_warnings
136 RESET MASTER;
137 RESET SLAVE;
138 --source include/rpl_connection_master.inc
139 RESET MASTER;
140 --source include/rpl_connection_slave.inc
141 --source include/start_slave.inc
142 --source include/rpl_connection_master.inc
143 DROP TABLE t1;
144 --source include/sync_slave_sql_with_master.inc
145 --enable_warnings
146 --source include/rpl_end.inc