Debian Codegraph @

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

raw
1 --source include/have_multi_ndb.inc
2 --source suite/ndb/include/backup_restore_setup.inc
3
4 #
5 # More tests related to metadata upgrade including
6 # upgrade of tables with different column types
7 # and disk data tables
8 #
9 # The backup consists of:
10 # CREATE TABLE t1 (
11 # c1 INT PRIMARY KEY AUTO_INCREMENT,
12 # c2 INT UNSIGNED NOT NULL,
13 # c3 FLOAT,
14 # c4 VARCHAR(255),
15 # c5 TIME,
16 # c6 DATE,
17 # c7 DATETIME,
18 # c8 BLOB,
19 # c9 CHAR(30),
20 # c10 VARBINARY(255),
21 # UNIQUE KEY xc2(c2)
22 # ) ENGINE NDB;
23 #
24 # INSERT INTO t1 VALUES(1,1,2.5,'a','23:59:59','2018-01-30','2018-01-30 13:46:00','b','c','d');
25 #
26 # CREATE TABLE t2 (
27 # c1 int PRIMARY KEY,
28 # c2 int GENERATED ALWAYS AS (c1*c1)
29 # ) ENGINE NDB;
30 #
31 # INSERT INTO t2(c1) VALUES(2);
32 #
33 # CREATE TABLE t3 (
34 # c1 int NOT NULL AUTO_INCREMENT PRIMARY KEY,
35 # c2 varchar(100),
36 # c3 varchar(100)
37 # ) ENGINE NDB
38 # COMMENT="NDB_TABLE=READ_BACKUP=0,PARTITION_BALANCE=FOR_RP_BY_NODE";
39 #
40 # INSERT INTO t3 VALUES(1,'a','a');
41 #
42
43 # Case 1: Metadata upgrade during schema synchronization
44
45 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m -r --disable-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
46 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 2 -r $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
47 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 --rebuild-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
48
49 --echo Backup from 7.5 restored
50
51 --echo Restart server 1 to trigger schema synchronization
52 let $mysqld_name=mysqld.1.1;
53 --source include/restart_mysqld.inc
54
55 connection server2;
56 --echo Restart server 2 to trigger schema synchronization
57 let $mysqld_name=mysqld.2.1;
58 --source include/restart_mysqld.inc
59
60 # Check schema and then perform DML and DDL on the tables
61 SHOW TABLES;
62 SHOW CREATE TABLE t1;
63 --sorted_result
64 SELECT * FROM t1;
65
66 ALTER TABLE t1 DROP COLUMN c9;
67 INSERT INTO t1 VALUES (2,2,2.5,'a','23:59:59','2018-01-30','2018-01-30 13:46:00','b','d');
68 --sorted_result
69 SELECT * FROM t1;
70
71 DROP TABLE t1;
72
73 SHOW CREATE TABLE t2;
74 --sorted_result
75 SELECT * FROM t2;
76
77 ALTER TABLE t2 RENAME t4;
78 INSERT INTO t4(c1) VALUES (3);
79 --sorted_result
80 SELECT * FROM t4;
81
82 DROP TABLE t4;
83
84 SHOW CREATE TABLE t3;
85 --sorted_result
86 SELECT * FROM t3;
87
88 ALTER TABLE t3 ALGORITHM=COPY, ADD COLUMN c4 int;
89 INSERT INTO t3 VALUES (2,'b','b',2);
90 --sorted_result
91 SELECT * FROM t3;
92
93 DROP TABLE t3;
94
95 # Case 2: Metadata upgrade during discovery from NDB
96
97 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m -r --disable-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
98 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 2 -r $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
99 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 --rebuild-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
100
101 SHOW CREATE TABLE t1;
102 --sorted_result
103 SELECT * FROM t1;
104
105 ALTER TABLE t1 DROP COLUMN c9;
106 INSERT INTO t1 VALUES (2,2,2.5,'a','23:59:59','2018-01-30','2018-01-30 13:46:00','b','d');
107 --sorted_result
108 SELECT * FROM t1;
109
110 DROP TABLE t1;
111
112 SHOW CREATE TABLE t2;
113 --sorted_result
114 SELECT * FROM t2;
115
116 connection server2;
117 SHOW CREATE TABLE t2;
118 connection server1;
119
120 ALTER TABLE t2 RENAME t4;
121 INSERT INTO t4(c1) VALUES (3);
122 --sorted_result
123 SELECT * FROM t4;
124
125 DROP TABLE t4;
126
127 SHOW CREATE TABLE t3;
128 --sorted_result
129 SELECT * FROM t3;
130
131 ALTER TABLE t3 ALGORITHM=COPY, ADD COLUMN c4 int;
132 INSERT INTO t3 VALUES (2,'b','b',2);
133 --sorted_result
134 SELECT * FROM t3;
135
136 DROP TABLE t3;
137
138 # Case 3: Check that tables restored with the --disable-indexes option are
139 # not automatically migrated. Synchronization of such tables
140 # would lead to the wrong table definition being installed in the DD
141 # and would render the table unusable until the indexes were restored
142 # to NDB
143
144 # Store initial counts of both detected and synchronized objects
145 --let $initial_detected_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1)
146 --let $initial_synced_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_synced_count', Value, 1)
147
148 --echo Restore metadata and data but do not create indexes
149 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m -r --disable-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
150 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 2 -r $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
151
152 --disable_query_log
153 # Suppress expected warnings due to missing indexes
154 CALL mtr.add_suppression("Metadata check has failed");
155 CALL mtr.add_suppression("The NDB Dictionary table definition is not identical");
156 CALL mtr.add_suppression("Diff in 'index_count'");
157 # Set low interval so changes are detected quickly
158 SET @old_ndb_metadata_check = @@global.ndb_metadata_check;
159 SET @old_ndb_metadata_check_interval = @@global.ndb_metadata_check_interval;
160 SET GLOBAL ndb_metadata_check = true;
161 SET GLOBAL ndb_metadata_check_interval = 5;
162 --enable_query_log
163
164 # Wait until the following 3 object changes are detected:
165 # Table 'test.t1'
166 # Table 'test.t2'
167 # Table 'test.t3'
168 --let $expected_changes = 3
169 --let $max_wait = 30
170 --source wait_metadata_changes_detected.inc
171
172 --disable_query_log
173 # Changes have been detected, reset values
174 SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
175 SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
176 --enable_query_log
177
178 # The above detected tables are never synced. They are instead treated
179 # as temporary errors. This scenario can be detected by waiting for them
180 # to be detected again which confirms that they've been removed from the
181 # queue but not synced and are also not currently excluded
182 --let $initial_detected_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1)
183
184 --disable_query_log
185 # Set low interval so changes are detected quickly
186 SET GLOBAL ndb_metadata_check = true;
187 SET GLOBAL ndb_metadata_check_interval = 5;
188 --enable_query_log
189
190 # Wait until the following 3 object changes are detected:
191 # Table 'test.t1'
192 # Table 'test.t2'
193 # Table 'test.t3'
194 --let $expected_changes = 3
195 --let $max_wait = 30
196 --source wait_metadata_changes_detected.inc
197
198 --disable_query_log
199 # Changes have been detected, reset values
200 SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
201 SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
202 --enable_query_log
203
204 --echo Confirm that the tables haven't been synced
205 SHOW TABLES;
206
207 --echo Rebuild indexes in NDB
208 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 --rebuild-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_advanced_backup >> $NDB_TOOLS_OUTPUT
209
210 # Indexes have been rebuilt which means that the tables are now
211 # ready to be synced
212 --let $initial_detected_count = query_get_value(SHOW STATUS LIKE 'Ndb_metadata_detected_count', Value, 1)
213 --disable_query_log
214 # Set low interval so changes are detected quickly
215 SET GLOBAL ndb_metadata_check = true;
216 SET GLOBAL ndb_metadata_check_interval = 0;
217 --enable_query_log
218
219 # Wait until the following 3 object changes are detected:
220 # Table 'test.t1'
221 # Table 'test.t2'
222 # Table 'test.t3'
223 --let $expected_changes = 3
224 --let $max_wait = 30
225 --source wait_metadata_changes_detected.inc
226
227 --disable_query_log
228 # Changes have been detected, reset values
229 SET GLOBAL ndb_metadata_check = @old_ndb_metadata_check;
230 SET GLOBAL ndb_metadata_check_interval = @old_ndb_metadata_check_interval;
231 --enable_query_log
232
233 --let $max_wait = 30
234 --source wait_metadata_synced.inc
235
236 --echo Confirm that the tables have been synced
237 SHOW TABLES;
238 --sorted_result
239 SELECT * FROM t1;
240 --sorted_result
241 SELECT * FROM t2;
242 --sorted_result
243 SELECT * FROM t3;
244
245 DROP TABLE t1,t2,t3;
246
247 #
248 # Metadata upgrade of a disk data table
249 # The backup consists of:
250 #
251 # CREATE LOGFILE GROUP lg1
252 # ADD UNDOFILE 'lg1_undofile.dat'
253 # INITIAL_SIZE 1M
254 # UNDO_BUFFER_SIZE = 1M
255 # ENGINE NDB;
256 #
257 # CREATE TABLESPACE ts1
258 # ADD DATAFILE 'ts1_datafile.dat'
259 # USE LOGFILE GROUP lg1
260 # INITIAL_SIZE 2M
261 # ENGINE NDB;
262 #
263 # CREATE TABLE t1 (
264 # a INT PRIMARY KEY,
265 # b VARCHAR(255)
266 # ) ENGINE NDB
267 # TABLESPACE ts1
268 # STORAGE DISK;
269 #
270 # INSERT INTO t1 VALUES (1,'Sad Cypress');
271 #
272
273 # Case 4: Metadata upgrade of a disk data table
274
275 --connection server1
276
277 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 -m -r --disable-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_disk_data_backup >> $NDB_TOOLS_OUTPUT
278 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 2 -r $NDB_SAVED_BACKUPS/metadata_upgrade_disk_data_backup >> $NDB_TOOLS_OUTPUT
279 --exec $NDB_RESTORE $NDB_RESTORE_NO_ENCR -b 1 -n 1 --rebuild-indexes $NDB_SAVED_BACKUPS/metadata_upgrade_disk_data_backup >> $NDB_TOOLS_OUTPUT
280 --echo Backup from 7.6 restored
281
282 --echo Restart server 1 to trigger schema synchronization
283 let $mysqld_name=mysqld.1.1;
284 --source include/restart_mysqld.inc
285 connection server2;
286 --echo Restart server 2 to trigger schema synchronization
287 let $mysqld_name=mysqld.2.1;
288 --source include/restart_mysqld.inc
289 connection server1;
290
291 # Check schema and then perform DML and DDL on the tables
292 SHOW TABLES;
293 SHOW CREATE TABLE t1;
294 --sorted_result
295 SELECT * FROM t1;
296
297 ALTER TABLE t1 DROP COLUMN b;
298 INSERT INTO t1 VALUES (2);
299 --sorted_result
300 SELECT * FROM t1;
301
302 DROP TABLE t1;
303 ALTER TABLESPACE ts1
304 DROP DATAFILE 'ts1_datafile.dat';
305 DROP TABLESPACE ts1;
306 DROP LOGFILE GROUP lg1
307 ENGINE NDB;
308
309 --remove_file $NDB_TOOLS_OUTPUT