Debian Codegraph @

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

raw
1 ########################################################################################
2 # This test verifies if the server migrates correctly from a file repository to a
3 # table repository and vice-versa. In particular, it checks if the information in the
4 # relay log info is correctly migrated between the different types (i.e. FILE or TABLE)
5 # of repositories. The algorithm and the function used to migrate the master info is
6 # the same and for that reason, we do not test its migration.
7 #
8 # If a FILE repository is used, the following assertions are valid:
9 # AF1. SELECT COUNT(*) FROM mysql.slave_relay_log_info == 0
10 # AF2. file_exists $MYSQLD_DATADIR/relay-log.info == 1
11 #
12 # If a TABLE repository is used, the following assertions are valid:
13 # AT1. SELECT COUNT(*) FROM mysql.slave_relay_log_info == 1
14 # AT2. file_exists $MYSQLD_DATADIR/relay-log.info == 0
15 #
16 # The test case is organized as follows:
17 #
18 # 1. Preparation:
19 # 1.1. The slave is started with a FILE repository enabled and the replication
20 # stopped.
21 # 1.2. A table is created and populated in order to check at the end of the test
22 # if data is replicated correctly.
23 # 1.3. Assertions AF1 and AF2 are verified.
24 #
25 # 2. Migration from FILE to TABLE by restarting the SERVER
26 # 2.1. The slave is stopped and restarted with --relay-log-info-repository=TABLE
27 # 2.2. Assertions AT1 and AT2 are verified.
28 #
29 # 3. Migration from TABLE to FILE by restarting the SERVER
30 # 4.1. The slave is stopped and restarted with --relay-log-info-repository=FILE
31 # 4.2. Assertions AF1 and AF2 are verified.
32 #
33 # 4. Migration from FILE to TALBE by using SET
34 # 4.1. SET @GLOBAL.relay_log_info_repository=TABLE is exectued.
35 # 4.2. Assertions AT1 and AT2 are verified.
36 #
37 # 5. Migration from TABLE to FILE by using SET
38 # 5.1. SET @GLOBAL.relay_log_info_repository=FILE is executed.
39 # 5.2. Assertions AF1 and AF2 are verified.
40 #
41 # 6. Migration from FILE to FILE by using SET
42 # 6.1. SET @GLOBAL.relay_log_info_repository=FILE is executed.
43 # 6.2. Assertions AF1 and AF2 are verified.
44 #
45 # 7. Migration while slave is running by using SET
46 # 7.1 Slave is started.
47 # 7.2. SET @GLOBAL.relay_log_info_repository=FILE is executed and fails.
48 # 7.3. Assertions AF1 and AF2 are verified.
49 #
50 # 8. Check consistency
51 # 8.1. The replication is started and the master is compared to the slave.
52 ########################################################################################
53 ########################################################################################
54 # 1. Preparation
55 ########################################################################################
56 --source include/not_group_replication_plugin.inc
57 --source include/not_valgrind.inc
58 --source include/not_mts_replica_parallel_workers.inc
59 --source include/master-slave.inc
60
61 --connection slave
62
63 let $MYSQLD_DATADIR= `SELECT @@datadir`;
64
65 let $exp_slave= 0;
66 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
67 if ($got_slave != $exp_slave)
68 {
69 --echo "The mysql.slave_relay_log_info has information and this is not expected."
70 --die
71 }
72 file_exists $MYSQLD_DATADIR/relay-log.info;
73
74 --source include/stop_slave.inc
75
76 --connection master
77
78 CREATE TABLE test(id INTEGER NOT NULL PRIMARY KEY);
79 INSERT INTO test VALUES (1), (2), (3);
80
81 ########################################################################################
82 # 2. Migration from FILE to TABLE by restarting the SERVER
83 ########################################################################################
84 --connection slave
85
86 --let $rpl_server_number= 2
87 --let $rpl_server_parameters= --relay-log-info-repository=TABLE --skip-replica-start
88 --source include/rpl_restart_server.inc
89
90 let $exp_slave= 1;
91 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
92 if ($got_slave != $exp_slave)
93 {
94 --echo "The mysql.slave_relay_log_info has no information and this is not expected."
95 --die
96 }
97 --error 1
98 file_exists $MYSQLD_DATADIR/relay-log.info;
99
100 ########################################################################################
101 # 3. Migration from TABLE to FILE by restarting the SERVER
102 ########################################################################################
103 --connection slave
104
105 --let $rpl_server_number= 2
106 --let $rpl_server_parameters= --relay-log-info-repository=FILE --skip-replica-start
107 --source include/rpl_restart_server.inc
108
109 let $exp_slave= 0;
110 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
111 if ($got_slave != $exp_slave)
112 {
113 --echo "The mysql.slave_relay_log_info has information and this is not expected."
114 --die
115 }
116 file_exists $MYSQLD_DATADIR/relay-log.info;
117
118 ########################################################################################
119 # 4. Migration FROM FILE TO TABLE by using SET
120 ########################################################################################
121 --connection slave
122
123 SET @@GLOBAL.relay_log_info_repository= "TABLE";
124
125 let $exp_slave= 1;
126 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
127 if ($got_slave != $exp_slave)
128 {
129 --echo "The mysql.slave_relay_log_info has no information and this is not expected."
130 --die
131 }
132 --error 1
133 file_exists $MYSQLD_DATADIR/relay-log.info;
134
135 ########################################################################################
136 # 5. Migration FROM TABLE TO FILE by using SET
137 ########################################################################################
138 --connection slave
139
140 SET @@GLOBAL.relay_log_info_repository= "FILE";
141
142 let $exp_slave= 0;
143 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
144 if ($got_slave != $exp_slave)
145 {
146 --echo "The mysql.slave_relay_log_info has information and this is not expected."
147 --die
148 }
149 file_exists $MYSQLD_DATADIR/relay-log.info;
150
151 ########################################################################################
152 # 6. Migration FROM FILE TO FILE by using SET
153 ########################################################################################
154 --connection slave
155
156 SET @@GLOBAL.relay_log_info_repository= "FILE";
157
158 let $exp_slave= 0;
159 let $got_slave= `SELECT COUNT(*) FROM mysql.slave_relay_log_info`;
160 if ($got_slave != $exp_slave)
161 {
162 --echo "The mysql.slave_relay_log_info has information and this is not expected."
163 --die
164 }
165 file_exists $MYSQLD_DATADIR/relay-log.info;
166
167 ########################################################################################
168 # 7. Migration while slave is running by using SET
169 ########################################################################################
170 --connection slave
171
172 #
173 # If the slave info repository is X, and the user sets the same repository
174 # again there is no need to stop the slave threads and the control return
175 # to client thread without doing anything. To make the test case pass in
176 # crash-safe-master i.e when --master-info-repository=TABLE, we convert
177 # the repo to FILE.
178 SET @@GLOBAL.master_info_repository= "FILE";
179
180 --source include/start_slave.inc
181
182 --error ER_REPLICA_CHANNEL_MUST_STOP
183 SET @@GLOBAL.relay_log_info_repository= "TABLE";
184
185 --error ER_REPLICA_CHANNEL_MUST_STOP
186 SET @@GLOBAL.master_info_repository= "TABLE";
187
188 ########################################################################################
189 # 8. Check consistency
190 ########################################################################################
191 --connection master
192
193 --source include/sync_slave_sql_with_master.inc
194 --exec $MYSQL_DUMP --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-migration-master.sql
195 --exec $MYSQL_DUMP_SLAVE --compact --order-by-primary --skip-extended-insert --no-create-info test > $MYSQLD_DATADIR/test-migration-slave.sql
196 --diff_files $MYSQLD_DATADIR/test-migration-master.sql $MYSQLD_DATADIR/test-migration-slave.sql
197
198 --connection master
199
200 DROP TABLE test;
201 --source include/sync_slave_sql_with_master.inc
202 --connection slave
203 --source include/stop_slave.inc
204 SET @@GLOBAL.master_info_repository= "TABLE";
205 --source include/start_slave.inc
206
207 #Cleanup
208 --source include/rpl_end.inc