Debian Codegraph @

mysql-test/suite/innodb/t/unknown_directory.test

raw
1 --echo #
2 --echo # Show what happens when --innodb-directories is modified
3 --echo # to ignore previously known directories.
4 --echo #
5
6 SET default_storage_engine=InnoDB;
7
8 --disable_query_log
9 LET $MYSQLD_DATADIR=`select @@datadir`;
10 LET $REMOTE_DIR=$MYSQL_TMP_DIR/remote_dir;
11 LET $INNODB_PAGE_SIZE=`select @@innodb_page_size`;
12 --mkdir $REMOTE_DIR
13 --enable_query_log
14
15 --echo # Restart the engine to make the remote directory known.
16 let $restart_parameters = restart: --innodb-directories=$REMOTE_DIR;
17 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
18 --source include/restart_mysqld.inc
19
20 --echo #
21 --echo # Create two tables in a known remote directory.
22 --echo #
23 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
24 eval CREATE TABLE t1(c1 INT) DATA DIRECTORY='$REMOTE_DIR';
25 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
26 SHOW CREATE TABLE t1;
27 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
28 eval CREATE TABLE t2(c1 INT, c2 INT) DATA DIRECTORY='$REMOTE_DIR';
29 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
30 SHOW CREATE TABLE t2;
31
32 --echo #
33 --echo # Create a general tablespace in a known remote directory.
34 --echo #
35 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
36 eval CREATE TABLESPACE ts1 ADD DATAFILE '$REMOTE_DIR/ts1.ibd';
37
38 --echo #
39 --echo # Create a table with a partitions in a known remote directory.
40 --echo #
41 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
42 eval CREATE TABLE tp1(c1 INT)
43 PARTITION BY HASH(c1) (
44 PARTITION p1 DATA DIRECTORY='$REMOTE_DIR',
45 PARTITION p2 DATA DIRECTORY='$REMOTE_DIR');
46 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
47 SHOW CREATE TABLE tp1;
48
49 --echo #
50 --echo # Create a table with a sub-partitions in a known remote directory.
51 --echo #
52 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
53 eval CREATE TABLE tsp1(c1 INT, c2 INT)
54 PARTITION BY RANGE(c1) SUBPARTITION BY HASH(c2) (
55 PARTITION p1 VALUES LESS THAN (10) (
56 SUBPARTITION s1 DATA DIRECTORY='$REMOTE_DIR',
57 SUBPARTITION s2 DATA DIRECTORY='$REMOTE_DIR'),
58 PARTITION p2 VALUES LESS THAN (20) (
59 SUBPARTITION s3 DATA DIRECTORY='$REMOTE_DIR',
60 SUBPARTITION s4 DATA DIRECTORY='$REMOTE_DIR'));
61 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
62 SHOW CREATE TABLE tsp1;
63
64 --echo #
65 --echo # Create two undo tablespaces in a known remote directory.
66 --echo #
67 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
68 eval CREATE UNDO TABLESPACE undo_003 ADD DATAFILE '$REMOTE_DIR/undo_003.ibu';
69 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
70 eval CREATE UNDO TABLESPACE undo_004 ADD DATAFILE '$REMOTE_DIR/undo_004.ibu';
71
72 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR \\ /
73 SELECT NAME, SPACE_TYPE, STATE FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
74 WHERE NAME LIKE 'undo_0%' ORDER BY NAME;
75
76 --echo #
77 --echo # Restart mysqld without the remote directory in --innodb-directories
78 --echo # and with one of the undo tablespaces deleted.
79 --echo #
80 --source include/shutdown_mysqld.inc
81 --remove_file $REMOTE_DIR/undo_004.ibu
82 let $restart_parameters = restart;
83 --source include/start_mysqld.inc
84
85 --echo #
86 --echo # Validate the messages that should have been put into the error log at startup.
87 --echo #
88 let SEARCH_FILE=$MYSQLTEST_VARDIR/log/mysqld.1.err;
89
90 let SEARCH_PATTERN=The datafile '.*' for tablespace undo_003 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
91 --source include/search_pattern.inc
92
93 let SEARCH_PATTERN=Tablespace .*, name 'undo_004', file '.*undo_004.ibu' is missing;
94 --source include/search_pattern.inc
95
96 let SEARCH_PATTERN=Cannot find undo tablespace undo_004 with filename '.*' as indicated by the Data Dictionary. Did you move or delete this tablespace. Any undo logs in it cannot be used;
97 --source include/search_pattern.inc
98
99 let SEARCH_PATTERN=The datafile '.*' for tablespace test/t1 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
100 --source include/search_pattern.inc
101
102 let SEARCH_PATTERN=The datafile '.*' for tablespace test/t2 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
103 --source include/search_pattern.inc
104
105 let SEARCH_PATTERN=The datafile '.*' for tablespace ts1 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
106 --source include/search_pattern.inc
107
108 let SEARCH_PATTERN=The datafile '.*' for tablespace test/tp1#p#p1 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
109 --source include/search_pattern.inc
110
111 let SEARCH_PATTERN=The datafile '.*' for tablespace test/tp1#p#p2 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
112 --source include/search_pattern.inc
113
114 let SEARCH_PATTERN=The datafile '.*' for tablespace test/tsp1#p#p1#sp#s1 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
115 --source include/search_pattern.inc
116
117 let SEARCH_PATTERN=The datafile '.*' for tablespace test/tsp1#p#p1#sp#s2 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
118 --source include/search_pattern.inc
119
120 let SEARCH_PATTERN=The datafile '.*' for tablespace test/tsp1#p#p1#sp#s3 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
121 --source include/search_pattern.inc
122
123 let SEARCH_PATTERN=The datafile '.*' for tablespace test/tsp1#p#p2#sp#s4 is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories;
124 --source include/search_pattern.inc
125
126 --echo #
127 --echo # Show the tablespaces
128 --echo #
129 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
130 SHOW CREATE TABLE t1;
131 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
132 SHOW CREATE TABLE t2;
133 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
134 SHOW CREATE TABLE tp1;
135 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
136 SHOW CREATE TABLE tsp1;
137 --source suite/innodb/include/show_i_s_tablespaces.inc
138
139 --echo #
140 --echo # If implicit tablespaces that exist in unknown locations are
141 --echo # part of a TRUNCATE statement, they will be recreated in
142 --echo # the default datadir location with a warning put into the error log.
143 --echo #
144 TRUNCATE TABLE t1;
145 SHOW WARNINGS;
146 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
147 SHOW CREATE TABLE t1;
148
149 TRUNCATE TABLE t2;
150 SHOW WARNINGS;
151 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
152 SHOW CREATE TABLE t1;
153
154 --source suite/innodb/include/show_i_s_tablespaces.inc
155
156 --echo #
157 --echo # EXCHANGE PARTITION does not recreate tablespaces, so files in unknown
158 --echo # locations will remain there through the exchange.
159 --echo #
160 ALTER TABLE tp1 EXCHANGE PARTITION p1 WITH TABLE t1;
161 SHOW WARNINGS;
162 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
163 SHOW CREATE TABLE t1;
164 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
165 SHOW CREATE TABLE tp1;
166
167 ALTER TABLE tsp1 EXCHANGE PARTITION s2 WITH TABLE t2;
168 SHOW WARNINGS;
169 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
170 SHOW CREATE TABLE t2;
171 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
172 SHOW CREATE TABLE tsp1;
173 --source suite/innodb/include/show_i_s_tablespaces.inc
174
175 TRUNCATE TABLE t2;
176 SHOW WARNINGS;
177 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
178 SHOW CREATE TABLE t2;
179 --source suite/innodb/include/show_i_s_tablespaces.inc
180
181 ALTER TABLE tsp1 EXCHANGE PARTITION s4 WITH TABLE t2;
182 SHOW WARNINGS;
183 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
184 SHOW CREATE TABLE t2;
185 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
186 SHOW CREATE TABLE tsp1;
187 --source suite/innodb/include/show_i_s_tablespaces.inc
188
189 --echo #
190 --echo # RENAME TABLE does not recreate tablespaces, so files in unknown
191 --echo # locations will remain there. No error message is issued.
192 --echo #
193 RENAME TABLE t1 to temp1;
194 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
195 SHOW CREATE TABLE temp1;
196 RENAME TABLE temp1 to t1;
197 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
198 SHOW CREATE TABLE t1;
199
200 --echo #
201 --echo # TRUNCATE the three tables to recreate all datafiles in the
202 --echo # default datafile location.
203 --echo #
204 TRUNCATE TABLE t1;
205 SHOW WARNINGS;
206 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
207 SHOW CREATE TABLE t1;
208
209 TRUNCATE TABLE t2;
210 SHOW WARNINGS;
211 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR
212 SHOW CREATE TABLE t2;
213
214 TRUNCATE TABLE tp1;
215 SHOW WARNINGS;
216 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
217 SHOW CREATE TABLE tp1;
218
219 TRUNCATE TABLE tsp1;
220 SHOW WARNINGS;
221 --replace_result $MYSQL_TMP_DIR MYSQL_TMP_DIR #P# #p# #SP# #sp#
222 SHOW CREATE TABLE tsp1;
223
224 --source suite/innodb/include/show_i_s_tablespaces.inc
225
226 --echo #
227 --echo # Validate the messages that should have been put into the error log.
228 --echo #
229 let SEARCH_PATTERN=Cannot create a tablespace for table test/t1 because the directory is not a valid location. The DATA DIRECTORY location must be in a known directory. The DATA DIRECTORY location will be ignored and the file will be put into the default datadir location;
230 --source include/search_pattern.inc
231
232 let SEARCH_PATTERN=Cannot create a tablespace for table test/t2 because the directory is not a valid location. The DATA DIRECTORY location must be in a known directory. The DATA DIRECTORY location will be ignored and the file will be put into the default datadir location;
233 --source include/search_pattern.inc
234
235 let SEARCH_PATTERN=Cannot create a tablespace for table test/tp1#p#p2 because the directory is not a valid location. The DATA DIRECTORY location must be in a known directory. The DATA DIRECTORY location will be ignored and the file will be put into the default datadir location;
236 --source include/search_pattern.inc
237
238 let SEARCH_PATTERN=Cannot create a tablespace for table test/tsp1#p#p1#sp#s1 because the directory is not a valid location. The DATA DIRECTORY location must be in a known directory. The DATA DIRECTORY location will be ignored and the file will be put into the default datadir location;
239 --source include/search_pattern.inc
240
241 let SEARCH_PATTERN=Cannot create a tablespace for table test/tsp1#p#p2#sp#s3 because the directory is not a valid location. The DATA DIRECTORY location must be in a known directory. The DATA DIRECTORY location will be ignored and the file will be put into the default datadir location;
242 --source include/search_pattern.inc
243
244 --echo #
245 --echo # Cleanup the IBD tablespaces
246 --echo #
247
248 DROP TABLE t1;
249 DROP TABLE t2;
250 DROP TABLE tp1;
251 DROP TABLE tsp1;
252 DROP TABLESPACE ts1;
253
254 --echo #
255 --echo # Cleanup the Undo IBU tablespaces
256 --echo #
257
258 SELECT NAME, SPACE_TYPE, STATE FROM INFORMATION_SCHEMA.INNODB_TABLESPACES
259 WHERE NAME LIKE 'undo_0%' ORDER BY NAME;
260 ALTER UNDO TABLESPACE undo_003 SET INACTIVE;
261 let $inactive_undo_space = undo_003;
262 source include/wait_until_undo_space_is_empty.inc;
263 DROP UNDO TABLESPACE undo_003;
264
265 # Even though I_S.INNODB_TABLESPACES says undo_004 is active, it is actually missing.
266 # See Bug#30871448: INNODB: INCONSISTENT AND INACCURATE MESSAGES WHEN A DATAFILE IS MISSING
267 DROP UNDO TABLESPACE undo_004;
268
269 --force-rmdir $REMOTE_DIR
270
271 --disable_query_log
272 call mtr.add_suppression("\\[Warning\\] .* Tablespace .*, name 'undo_004', file '.*undo_004.ibu' is missing");
273 call mtr.add_suppression("\\[ERROR\\] .* Cannot find undo tablespace undo_004 with filename '.*' as indicated by the Data Dictionary. Did you move or delete this tablespace. Any undo logs in it cannot be used");
274 call mtr.add_suppression("\\[Warning\\] .* The datafile '.*' for tablespace .* is in an unprotected location. This file cannot be recovered after a crash until this location is added to innodb_directories");
275 call mtr.add_suppression("\\[Warning\\] .* Trying to access missing tablespace");
276 call mtr.add_suppression("\\[Warning\\] .* Cannot create a tablespace for table .* because the directory is not a valid location. The DATA DIRECTORY location must be in a known directory");
277 --enable_query_log
278