Debian Codegraph @

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

raw
1 ###############################################################################
2 #Bug#19012085 SETTING GTID_PURGED MAY BREAK AUTO_POSITION AND THUS SLAVES
3 # Problem:
4 # When slave asks for GTIDs which were purged by Master, Master is silently
5 # ignoring it and sending the GTIDs whatever is available.
6 # Fix:
7 # Slave's I/O thread, when connecting to Master, should be aborted with an
8 # error "Master has purged binary logs containing GTIDs that the slave
9 # requires."
10 # Steps to reproduce:
11 # 1) Set GTID_PURGED=UUID:1-2 on Master
12 # 2) Execute some dummy transactions (GTID:3-4)
13 # 3) A new slave request Master to send GTIDs
14 # 4) Master should throw error instead of silently sending GTIDs 3 and 4.
15 ###############################################################################
16
17 --source include/not_group_replication_plugin.inc
18 --source include/have_binlog_format_statement.inc
19 --let $rpl_skip_start_slave= 1
20 --source include/master-slave.inc
21
22 # Step-1) Master wants to set 1 and 2 GTIDs in GTID_PURGED
23 --let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
24 --replace_result $master_uuid master_uuid
25 --eval SET GLOBAL GTID_PURGED= "$master_uuid:1"
26
27 # Verify that the value can begin with a plus sign for setting GTID_PURGED
28 --replace_result $master_uuid master_uuid
29 --eval SET GLOBAL GTID_PURGED= "+$master_uuid:2"
30
31 # Step-2) Do some dummy transactions
32 CALL mtr.add_suppression(".*Cannot replicate.*purged required binary logs.*"); # GTID-3
33 CREATE TABLE t1(i INT); # GTID-4
34 DROP TABLE t1; # GTID-5
35
36 # Step-3) Start Slave IO thread which will request Master to send all
37 # transactions.
38 --connection slave
39 --replace_result $master_uuid master_uuid
40 --eval SET GLOBAL GTID_PURGED = "$master_uuid:1"
41 START SLAVE IO_THREAD;
42
43 # Step-4)since Master has already purged binary logs containing GTID 1 and 2,
44 # it should throw error and I/O thread should not be started.
45 #013114 = ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG
46 --let $slave_io_errno= 13114
47 --let $show_slave_io_error= 1
48 --let $slave_io_error_replace= /$master_uuid/MASTER_UUID/
49 --source include/wait_for_slave_io_error.inc
50
51 # Fix the problem by setting GTID_PURGED on Slave as well.
52 --replace_result $master_uuid master_uuid
53 --eval SET GLOBAL GTID_PURGED= "$master_uuid:1-2"
54
55 # Now start slave threads. Slave will ask Master to send all GTIDs
56 # except GTID:1-2 which should not be a problem and should not throw
57 # any errors.
58 --source include/start_slave.inc
59 --connection master
60 --source include/sync_slave_sql_with_master.inc
61
62 --let $assert_text= Slave should be able to get GTID-3 and 4 now.
63 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$master_uuid:1-5"
64 --source include/assert.inc
65
66 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.err
67 --let $assert_match= .*Cannot replicate to server with server_uuid.*The missing transactions are '$master_uuid:2'.*
68 --let $assert_select= Cannot replicate to server with server_uuid
69 --let $assert_text= Found warning continaining lost GTIDs
70 --source include/assert_grep.inc
71
72 ###############################################################################
73 #Bug #18789758 DATA INCONSISTENCIES WHEN MASTER HAS TRUNCATED BINARY LOG WITH
74 # GTID AFTER CRASH
75 # Problem:
76 # Master's dump thread is not detecting the case where Slave's gtid executed
77 # set is having more gtids than Master's gtid executed set with respective
78 # to Master's UUID.
79 # Fix:
80 # If it happens, dump thread will be stopped during the handshake
81 # with Slave(thus the Slave's I/O thread will be stopped with the
82 # error). Otherwise, it can lead to data inconsistency
83 # between Master and Slave.
84 #
85 # Steps to reproduce:
86 # 1) Execute some sample gtid transactions on Master
87 # 2) Let it reach Slave
88 # 3) Fake raid failure( by manually deleting binary log file)
89 # 4) Restart Master, thus removing those gtids from executed gtid set.
90 # 5) Restart slave's I/O thread, Slave sends its gtids which are purged on
91 # Master
92 # 6) Make sure I/O thread gets error and informs the situation to the Slave.
93 # 7) Verify that situation is recovered back normal after setting GTID_PURGED
94 # value to those purged gtids.
95 ###############################################################################
96
97 # Cleanup from the next test script
98 --connection master
99 --source include/rpl_reset.inc
100
101 # Step-1) Execute some sample gtid transactions on Master
102 CREATE TABLE t1(i INT);
103 DROP TABLE t1;
104
105 # Step-2) Let it reach Slave.
106 --sync_slave_with_master
107 --source include/stop_slave.inc
108
109 # Step-3) Fake raid failure( by manually deleting binary log file)
110 --connection master
111 --let $master_datadir= `SELECT @@datadir;`
112 FLUSH LOGS;
113 DELETE FROM mysql.gtid_executed;
114 --remove_file $master_datadir/master-bin.000001
115 --remove_file $master_datadir/master-bin.000002
116 --remove_file $master_datadir/master-bin.index
117
118 # Step-4) Restart Master, thus removing those gtids from executed gtid set.
119 --let $rpl_server_number= 1
120 --source include/rpl_restart_server.inc
121 # Step-5) Restart slave's I/O thread, Slave sends its gtids which are purged on Master
122 --connection slave
123 START SLAVE IO_THREAD;
124
125 # Step-6) Make sure I/O thread gets error and informs the situation to the Slave.
126 --let $slave_io_errno=13114
127 #convert_error(ER_SERVER_SOURCE_FATAL_ERROR_READING_BINLOG)
128 --let $show_slave_io_error= 1
129 --source include/wait_for_slave_io_error.inc
130 call mtr.add_suppression(".*Replica has more GTIDs than the source has.*");
131
132 # Step-7) Verify that situation is recovered back normal after setting GTID_PURGED
133 # value to those purged gtids.
134 --connection master
135 --let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
136 --replace_result $master_uuid master_uuid
137 --eval SET GLOBAL GTID_PURGED= "$master_uuid:1-2"
138
139 --connection slave
140 --source include/start_slave.inc
141
142 # Cleanup
143 --source include/rpl_end.inc