Debian Codegraph @

mysql-test/suite/ndb/t/ndb_dd_schema_synchronization.test

raw
1 --source include/have_multi_ndb.inc
2 --source suite/ndb/include/backup_restore_setup.inc
3
4 --echo "MySQL Server 1"
5
6 # Create logfile group
7 CREATE LOGFILE GROUP lg1
8 ADD UNDOFILE 'lg1_undofile.dat'
9 INITIAL_SIZE 1M
10 UNDO_BUFFER_SIZE = 1M
11 ENGINE=NDB;
12
13 # Create tablespaces using the logfile group
14 CREATE TABLESPACE ts1
15 ADD DATAFILE 'ts1_datafile.dat'
16 USE LOGFILE GROUP lg1
17 INITIAL_SIZE 2M
18 ENGINE NDB;
19
20 CREATE TABLESPACE ts2
21 ADD DATAFILE 'ts2_datafile.dat'
22 USE LOGFILE GROUP lg1
23 INITIAL_SIZE 2M
24 ENGINE NDB;
25
26 CREATE TABLESPACE ts3
27 ADD DATAFILE 'ts3_datafile.dat'
28 USE LOGFILE GROUP lg1
29 INITIAL_SIZE 2M
30 ENGINE NDB;
31
32 # Scenario 1:
33 # Tablespaces and logfile group exist in NDB but not DD.
34 # This is done by taking a backup, dropping the objects
35 # and then restoring the backup. The synchronization
36 # install the objects on both server1 and server2
37
38 --echo "Start Backup"
39 --exec $NDB_MGM -e "start backup" >> $NDB_TOOLS_OUTPUT
40
41 ALTER TABLESPACE ts1
42 DROP DATAFILE 'ts1_datafile.dat';
43 DROP TABLESPACE ts1;
44
45 ALTER TABLESPACE ts2
46 DROP DATAFILE 'ts2_datafile.dat';
47 DROP TABLESPACE ts2;
48
49 ALTER TABLESPACE ts3
50 DROP DATAFILE 'ts3_datafile.dat';
51 DROP TABLESPACE ts3;
52
53 DROP LOGFILE GROUP lg1
54 ENGINE=NDB;
55
56 --source include/ndb_backup_id.inc
57
58 --echo "Restore backup"
59 --exec $NDB_RESTORE -b $the_backup_id -n 1 -m $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
60
61 let $mysqld_name=mysqld.1.1;
62 --source include/restart_mysqld.inc
63
64 connection server2;
65 let $mysqld_name=mysqld.2.1;
66 --source include/restart_mysqld.inc
67
68 connection server1;
69
70 # Check if the logfile group and tablespaces have been successfully synchronized.
71 # We do this by trying to create them again which should fail
72 --error ER_CREATE_FILEGROUP_FAILED
73 CREATE LOGFILE GROUP lg1
74 ADD UNDOFILE 'lg1_undofile.dat'
75 INITIAL_SIZE 1M
76 UNDO_BUFFER_SIZE = 1M
77 ENGINE=NDB;
78 SHOW WARNINGS;
79
80 --error ER_TABLESPACE_EXISTS
81 CREATE TABLESPACE ts1
82 ADD DATAFILE 'ts1_datafile.dat'
83 USE LOGFILE GROUP lg1
84 INITIAL_SIZE 2M
85 ENGINE NDB;
86
87 --error ER_TABLESPACE_EXISTS
88 CREATE TABLESPACE ts2
89 ADD DATAFILE 'ts2_datafile.dat'
90 USE LOGFILE GROUP lg1
91 INITIAL_SIZE 2M
92 ENGINE NDB;
93
94 --error ER_TABLESPACE_EXISTS
95 CREATE TABLESPACE ts3
96 ADD DATAFILE 'ts3_datafile.dat'
97 USE LOGFILE GROUP lg1
98 INITIAL_SIZE 2M
99 ENGINE NDB;
100
101 # Scenario 2:
102 # DD contains outdated metadata when compared to NDB Dictionary.
103 # a) DROP and then re-CREATE logfile group and tablespace in server1 while
104 # server2 is down (to prevent schema distribution). When server2 reconnects
105 # it detects a change in version and the logfile group is reinstalled
106 # b) ALTER tablespace/logfile group in server1 while server2 is down
107
108 connection server2;
109
110 # Write file to make mysql-test-run.pl expect the restart, but don't start
111 # it until it's told to
112 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.1.expect
113 wait
114 EOF
115 # Send shutdown to the connected server
116 --shutdown_server
117 # Check if server is gone
118 --source include/wait_until_disconnected.inc
119
120 connection server1;
121
122 ALTER TABLESPACE ts1
123 DROP DATAFILE 'ts1_datafile.dat';
124 DROP TABLESPACE ts1;
125
126 CREATE TABLESPACE ts1
127 ADD DATAFILE 'ts1_datafile.dat'
128 USE LOGFILE GROUP lg1
129 INITIAL_SIZE 2M
130 ENGINE NDB;
131
132 ALTER TABLESPACE ts2
133 ADD DATAFILE 'ts2_datafile2.dat';
134
135 ALTER TABLESPACE ts3
136 ADD DATAFILE 'ts3_datafile2.dat';
137 ALTER TABLESPACE ts3
138 DROP DATAFILE 'ts3_datafile.dat';
139
140 ALTER LOGFILE GROUP lg1
141 ADD UNDOFILE 'lg1_undofile2.dat'
142 ENGINE=NDB;
143
144 connection server2;
145 # Write file to make mysql-test-run.pl start up the server again
146 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.2.1.expect
147 restart
148 EOF
149 # Turn on reconnect
150 --enable_reconnect
151 # Call script that will poll the server waiting for it to be back online again
152 --source include/wait_until_connected_again.inc
153 # Turn off reconnect again
154 --disable_reconnect
155
156 --echo "MySQL Server 2 after reconnect"
157
158 # Once again check if synchronization has been sucessful by repeating the same
159 # schema operations which are expected to now fail
160 --error ER_TABLESPACE_EXISTS
161 CREATE TABLESPACE ts1
162 ADD DATAFILE 'ts1_datafile.dat'
163 USE LOGFILE GROUP lg1
164 INITIAL_SIZE 2M
165 ENGINE NDB;
166
167 --error ER_ALTER_FILEGROUP_FAILED
168 ALTER TABLESPACE ts2
169 ADD DATAFILE 'ts2_datafile2.dat';
170 SHOW WARNINGS;
171
172 --error ER_ALTER_FILEGROUP_FAILED
173 ALTER TABLESPACE ts3
174 ADD DATAFILE 'ts3_datafile2.dat';
175 SHOW WARNINGS;
176 --error ER_MISSING_TABLESPACE_FILE
177 ALTER TABLESPACE ts3
178 DROP DATAFILE 'ts3_datafile.dat';
179
180 --error ER_ALTER_FILEGROUP_FAILED
181 ALTER LOGFILE GROUP lg1
182 ADD UNDOFILE 'lg1_undofile2.dat'
183 ENGINE=NDB;
184 SHOW WARNINGS;
185
186 # Scenario 3:
187 # Logfile group and tablespaces exist in DD but not NDB. This
188 # is achieved by dropping the objects from server2 while
189 # server1 is down. server1 then drops the objects when
190 # it reconnects to the cluster
191
192 connection server1;
193
194 # Write file to make mysql-test-run.pl expect the restart, but don't start
195 # it until it's told to
196 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
197 wait
198 EOF
199 # Send shutdown to the connected server
200 --shutdown_server
201 # Check if server is gone
202 --source include/wait_until_disconnected.inc
203
204 connection server2;
205
206 ALTER TABLESPACE ts1
207 DROP DATAFILE 'ts1_datafile.dat';
208 DROP TABLESPACE ts1;
209
210 ALTER TABLESPACE ts2
211 DROP DATAFILE 'ts2_datafile.dat';
212 ALTER TABLESPACE ts2
213 DROP DATAFILE 'ts2_datafile2.dat';
214 DROP TABLESPACE ts2;
215
216 ALTER TABLESPACE ts3
217 DROP DATAFILE 'ts3_datafile2.dat';
218 DROP TABLESPACE ts3;
219
220 DROP LOGFILE GROUP lg1
221 ENGINE=NDB;
222
223 connection server1;
224
225 # Write file to make mysql-test-run.pl start up the server again
226 --append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.1.expect
227 restart
228 EOF
229 # Turn on reconnect
230 --enable_reconnect
231 # Call script that will poll the server waiting for it to be back online again
232 --source include/wait_until_connected_again.inc
233 # Turn off reconnect again
234 --disable_reconnect
235
236 --echo "MySQL Server 1 after reconnect"
237
238 # Check if the DROP queries fail as expected
239 --error ER_TABLESPACE_MISSING_WITH_NAME
240 DROP TABLESPACE ts1;
241
242 --error ER_TABLESPACE_MISSING_WITH_NAME
243 DROP TABLESPACE ts2;
244
245 --error ER_TABLESPACE_MISSING_WITH_NAME
246 DROP TABLESPACE ts3;
247
248 --error ER_DROP_FILEGROUP_FAILED
249 DROP LOGFILE GROUP lg1
250 ENGINE=NDB;
251 SHOW WARNINGS;
252
253 #
254 # Check if the tablespace id for disk data tables is set
255 # during synchronization
256 #
257
258 CREATE LOGFILE GROUP lg1
259 ADD UNDOFILE 'lg1_undofile.dat'
260 INITIAL_SIZE 1M
261 UNDO_BUFFER_SIZE = 1M
262 ENGINE NDB;
263
264 CREATE TABLESPACE ts1
265 ADD DATAFILE 'ts1_datafile.dat'
266 USE LOGFILE GROUP lg1
267 INITIAL_SIZE 2M
268 ENGINE NDB;
269
270 CREATE TABLE t1 (
271 a INT PRIMARY KEY,
272 b VARCHAR(255)
273 ) ENGINE NDB
274 TABLESPACE ts1
275 STORAGE DISK;
276
277 SHOW CREATE TABLE t1;
278
279 # backup
280 --disable_query_log
281 --source include/ndb_backup.inc
282 --enable_query_log
283
284 DROP TABLE t1;
285
286 ALTER TABLESPACE ts1
287 DROP DATAFILE 'ts1_datafile.dat';
288 DROP TABLESPACE ts1;
289
290 DROP LOGFILE GROUP lg1
291 ENGINE NDB;
292
293 --exec $NDB_RESTORE -b $the_backup_id -n 1 -m $NDB_BACKUPS-$the_backup_id >> $NDB_TOOLS_OUTPUT
294
295 let $mysqld_name=mysqld.1.1;
296 --source include/restart_mysqld.inc
297 --connection server2
298 let $mysqld_name=mysqld.2.1;
299 --source include/restart_mysqld.inc
300 --connection server1
301
302 SHOW CREATE TABLE t1;
303 --connection server2
304 SHOW CREATE TABLE t1;
305 --connection server1
306 INSERT INTO t1 VALUES(1,'a');
307 SELECT * FROM t1;
308 ALTER TABLE t1 DROP COLUMN b;
309 DROP TABLE t1;
310 ALTER TABLESPACE ts1
311 DROP DATAFILE 'ts1_datafile.dat';
312 DROP TABLESPACE ts1;
313 DROP LOGFILE GROUP lg1
314 ENGINE NDB;
315
316 --source suite/ndb/include/backup_restore_cleanup.inc
317 --remove_file $NDB_TOOLS_OUTPUT