| 1 |
# Slow shutdown and restart to make sure ibuf merge is finished |
| 2 |
SET GLOBAL innodb_fast_shutdown = 0; |
| 3 |
--source include/restart_mysqld.inc |
| 4 |
|
| 5 |
--let $restart_parameters = "restart: --innodb_doublewrite=detect_only" |
| 6 |
|
| 7 |
--disable_query_log |
| 8 |
call mtr.add_suppression("Database page [0-9]+:1 contained only zeroes."); |
| 9 |
call mtr.add_suppression("Header page consists of zero bytes"); |
| 10 |
call mtr.add_suppression("Checksum mismatch in datafile"); |
| 11 |
call mtr.add_suppression("but the innodb_page_size start-up parameter is"); |
| 12 |
call mtr.add_suppression("Database page corruption"); |
| 13 |
call mtr.add_suppression("Wrong server version"); |
| 14 |
--enable_query_log |
| 15 |
|
| 16 |
let INNODB_PAGE_SIZE=`select @@innodb_page_size`; |
| 17 |
let MYSQLD_DATADIR=`select @@datadir`; |
| 18 |
|
| 19 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 20 |
SHOW VARIABLES LIKE 'innodb_fil_make_page_dirty_debug'; |
| 21 |
SHOW VARIABLES LIKE 'innodb_saved_page_number_debug'; |
| 22 |
|
| 23 |
create table t1 (f1 int primary key, f2 blob) engine=innodb; |
| 24 |
|
| 25 |
START TRANSACTION; |
| 26 |
INSERT INTO t1 VALUES(1, repeat('#',12)); |
| 27 |
INSERT INTO t1 VALUES(2, repeat('+',12)); |
| 28 |
INSERT INTO t1 VALUES(3, repeat('/',12)); |
| 29 |
INSERT INTO t1 VALUES(4, repeat('-',12)); |
| 30 |
INSERT INTO t1 VALUES(5, repeat('.',12)); |
| 31 |
COMMIT WORK; |
| 32 |
|
| 33 |
--echo # --------------------------------------------------------------- |
| 34 |
--echo # Test Begin: Test if recovery works if first page of user |
| 35 |
--echo # tablespace is full of zeroes. |
| 36 |
|
| 37 |
--echo # Wait for purge to complete |
| 38 |
--source include/wait_innodb_all_purged.inc |
| 39 |
|
| 40 |
--echo # Ensure that dirty pages of table t1 is flushed. |
| 41 |
FLUSH TABLES t1 FOR EXPORT; |
| 42 |
UNLOCK TABLES; |
| 43 |
|
| 44 |
SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACEs |
| 45 |
WHERE name = 'test/t1' INTO @space_id; |
| 46 |
|
| 47 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 48 |
|
| 49 |
SET GLOBAL innodb_doublewrite=DETECT_ONLY; |
| 50 |
SELECT @@innodb_doublewrite; |
| 51 |
|
| 52 |
INSERT INTO t1 VALUES(7, repeat('.',12)); |
| 53 |
|
| 54 |
SELECT @@innodb_doublewrite; |
| 55 |
SET GLOBAL innodb_doublewrite=ON; |
| 56 |
SELECT @@innodb_doublewrite; |
| 57 |
|
| 58 |
BEGIN; |
| 59 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 60 |
|
| 61 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 62 |
|
| 63 |
--echo # Make the first page dirty for table t1 |
| 64 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 65 |
|
| 66 |
# Set the page dirty and force a flush to disk |
| 67 |
--source include/expect_crash.inc |
| 68 |
--error CR_SERVER_LOST |
| 69 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 70 |
|
| 71 |
--echo # Make the first page (page_no=0) of the user tablespace |
| 72 |
--echo # full of zeroes. |
| 73 |
--let IBD_FILE=$MYSQLD_DATADIR/test/t1.ibd |
| 74 |
--let PAGE_NUM="0" |
| 75 |
--let ALL_ZEROES=1 |
| 76 |
--source corrupt_page.inc |
| 77 |
|
| 78 |
--source include/start_mysqld.inc |
| 79 |
|
| 80 |
CHECK TABLE t1; |
| 81 |
SELECT f1, f2 FROM t1; |
| 82 |
|
| 83 |
--echo # Test End |
| 84 |
--echo # --------------------------------------------------------------- |
| 85 |
--echo # Test Begin: Test if recovery works if first page of user |
| 86 |
--echo # tablespace is corrupted. |
| 87 |
|
| 88 |
SELECT space from INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 89 |
WHERE name = 'test/t1' INTO @space_id; |
| 90 |
|
| 91 |
--echo # Ensure that dirty pages of table t1 is flushed. |
| 92 |
FLUSH TABLES t1 FOR EXPORT; |
| 93 |
UNLOCK TABLES; |
| 94 |
|
| 95 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 96 |
|
| 97 |
SELECT @@innodb_doublewrite; |
| 98 |
SET GLOBAL innodb_doublewrite=ON; |
| 99 |
SELECT @@innodb_doublewrite; |
| 100 |
|
| 101 |
BEGIN; |
| 102 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 103 |
|
| 104 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 105 |
|
| 106 |
--echo # Make the first page dirty for table t1 |
| 107 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 108 |
|
| 109 |
# Set the page dirty and force a flush to disk |
| 110 |
--source include/expect_crash.inc |
| 111 |
--error CR_SERVER_LOST |
| 112 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 113 |
|
| 114 |
--echo # Corrupt the first page (page_no=0) of the user tablespace. |
| 115 |
--let IBD_FILE=$MYSQLD_DATADIR/test/t1.ibd |
| 116 |
--let PAGE_NUM="0" |
| 117 |
--source corrupt_page.inc |
| 118 |
|
| 119 |
--source include/start_mysqld.inc |
| 120 |
|
| 121 |
CHECK TABLE t1; |
| 122 |
SELECT f1, f2 FROM t1; |
| 123 |
|
| 124 |
--echo # Test End |
| 125 |
--echo # --------------------------------------------------------------- |
| 126 |
--echo # Test Begin: Test if recovery works if 2nd page of user |
| 127 |
--echo # tablespace is full of zeroes. |
| 128 |
|
| 129 |
SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 130 |
WHERE name = 'test/t1' INTO @space_id; |
| 131 |
|
| 132 |
--echo # Ensure that dirty pages of table t1 is flushed. |
| 133 |
FLUSH TABLES t1 FOR EXPORT; |
| 134 |
UNLOCK TABLES; |
| 135 |
|
| 136 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 137 |
|
| 138 |
SELECT @@innodb_doublewrite; |
| 139 |
SET GLOBAL innodb_doublewrite=ON; |
| 140 |
SELECT @@innodb_doublewrite; |
| 141 |
|
| 142 |
BEGIN; |
| 143 |
INSERT INTO t1 VALUES (6, repeat('%', 400)); |
| 144 |
|
| 145 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 146 |
|
| 147 |
--echo # Make the 2nd page dirty for table t1 |
| 148 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 149 |
|
| 150 |
# Set the page dirty and force a flush to disk |
| 151 |
--source include/expect_crash.inc |
| 152 |
--error CR_SERVER_LOST |
| 153 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 154 |
|
| 155 |
--echo # Make the 2nd page (page_no=1) of the tablespace all zeroes. |
| 156 |
--let IBD_FILE=$MYSQLD_DATADIR/test/t1.ibd |
| 157 |
--let PAGE_NUM=1 |
| 158 |
--let ALL_ZEROES=1 |
| 159 |
--source corrupt_page.inc |
| 160 |
|
| 161 |
--source include/start_mysqld.inc |
| 162 |
|
| 163 |
CHECK TABLE t1; |
| 164 |
SELECT f1, f2 FROM t1; |
| 165 |
|
| 166 |
--echo # Test End |
| 167 |
--echo # --------------------------------------------------------------- |
| 168 |
--echo # Test Begin: Test if recovery works if 2nd page of user |
| 169 |
--echo # tablespace is corrupted. |
| 170 |
|
| 171 |
SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 172 |
WHERE name = 'test/t1' into @space_id; |
| 173 |
|
| 174 |
--echo # Ensure that dirty pages of table t1 is flushed. |
| 175 |
FLUSH TABLES t1 FOR EXPORT; |
| 176 |
UNLOCK TABLES; |
| 177 |
|
| 178 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 179 |
|
| 180 |
SELECT @@innodb_doublewrite; |
| 181 |
SET GLOBAL innodb_doublewrite=ON; |
| 182 |
SELECT @@innodb_doublewrite; |
| 183 |
|
| 184 |
BEGIN; |
| 185 |
INSERT INTO t1 VALUES (6, repeat('%', 400)); |
| 186 |
|
| 187 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 188 |
|
| 189 |
--echo # Make the 2nd page dirty for table t1 |
| 190 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 191 |
|
| 192 |
# Set the page dirty and force a flush to disk |
| 193 |
--source include/expect_crash.inc |
| 194 |
--error CR_SERVER_LOST |
| 195 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 196 |
|
| 197 |
--echo # Corrupt the 2nd page (page_no=1) of the user tablespace. |
| 198 |
--let IBD_FILE=$MYSQLD_DATADIR/test/t1.ibd |
| 199 |
--let PAGE_NUM=1 |
| 200 |
--source corrupt_page.inc |
| 201 |
|
| 202 |
--source include/start_mysqld.inc |
| 203 |
|
| 204 |
CHECK TABLE t1; |
| 205 |
SELECT f1, f2 FROM t1; |
| 206 |
|
| 207 |
--echo # Test End |
| 208 |
--echo # --------------------------------------------------------------- |
| 209 |
--echo # Test Begin: Test if recovery works if first page of |
| 210 |
--echo # system tablespace is full of zeroes. |
| 211 |
|
| 212 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 213 |
|
| 214 |
SELECT @@innodb_doublewrite; |
| 215 |
SET GLOBAL innodb_doublewrite=ON; |
| 216 |
SELECT @@innodb_doublewrite; |
| 217 |
|
| 218 |
BEGIN; |
| 219 |
INSERT INTO t1 VALUES (6, repeat('%', 400)); |
| 220 |
|
| 221 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 222 |
|
| 223 |
--echo # Make the first page dirty for system tablespace |
| 224 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 225 |
|
| 226 |
# Set the page dirty and force a flush to disk |
| 227 |
--source include/expect_crash.inc |
| 228 |
--error CR_SERVER_LOST |
| 229 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 230 |
|
| 231 |
--echo # Make the first page (page_no=0) of the system tablespace |
| 232 |
--echo # all zeroes. |
| 233 |
--let IBD_FILE=$MYSQLD_DATADIR/ibdata1 |
| 234 |
--let PAGE_NUM="0" |
| 235 |
--let ALL_ZEROES=1 |
| 236 |
--source corrupt_page.inc |
| 237 |
|
| 238 |
--source include/start_mysqld.inc |
| 239 |
|
| 240 |
CHECK TABLE t1; |
| 241 |
SELECT f1, f2 FROM t1; |
| 242 |
|
| 243 |
--echo # Test End |
| 244 |
--echo # --------------------------------------------------------------- |
| 245 |
--echo # Test Begin: Test if recovery works if first page of |
| 246 |
--echo # system tablespace is corrupted. |
| 247 |
|
| 248 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 249 |
|
| 250 |
SELECT @@innodb_doublewrite; |
| 251 |
SET GLOBAL innodb_doublewrite=ON; |
| 252 |
SELECT @@innodb_doublewrite; |
| 253 |
|
| 254 |
BEGIN; |
| 255 |
INSERT INTO t1 VALUES (6, repeat('%', 400)); |
| 256 |
|
| 257 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 258 |
|
| 259 |
--echo # Make the first page dirty for system tablespace |
| 260 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 261 |
|
| 262 |
# Set the page dirty and force a flush to disk |
| 263 |
--source include/expect_crash.inc |
| 264 |
--error CR_SERVER_LOST |
| 265 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 266 |
|
| 267 |
--echo # Corrupt the first page (page_no=0) of the system tablespace. |
| 268 |
--let IBD_FILE=$MYSQLD_DATADIR/ibdata1 |
| 269 |
--let PAGE_NUM="0" |
| 270 |
--source corrupt_page.inc |
| 271 |
|
| 272 |
--source include/start_mysqld.inc |
| 273 |
|
| 274 |
CHECK TABLE t1; |
| 275 |
SELECT f1, f2 FROM t1; |
| 276 |
|
| 277 |
--echo # Test End |
| 278 |
--echo # --------------------------------------------------------------- |
| 279 |
--echo # Test Begin: Test if recovery works if 2nd page of |
| 280 |
--echo # system tablespace is full of zeroes. |
| 281 |
|
| 282 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 283 |
|
| 284 |
SELECT @@innodb_doublewrite; |
| 285 |
SET GLOBAL innodb_doublewrite=ON; |
| 286 |
SELECT @@innodb_doublewrite; |
| 287 |
|
| 288 |
BEGIN; |
| 289 |
INSERT INTO t1 VALUES (6, repeat('%', 400)); |
| 290 |
|
| 291 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 292 |
|
| 293 |
--echo # Make the second page dirty for system tablespace |
| 294 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 295 |
|
| 296 |
# Set the page dirty and force a flush to disk |
| 297 |
--source include/expect_crash.inc |
| 298 |
--error CR_SERVER_LOST |
| 299 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 300 |
|
| 301 |
--echo # Make the 2nd page (page_no=1) of the system tablespace |
| 302 |
--echo # all zeroes. |
| 303 |
--let IBD_FILE=$MYSQLD_DATADIR/ibdata1 |
| 304 |
--let PAGE_NUM=1 |
| 305 |
--let ALL_ZEROES=1 |
| 306 |
--source corrupt_page.inc |
| 307 |
|
| 308 |
--source include/start_mysqld.inc |
| 309 |
|
| 310 |
CHECK TABLE t1; |
| 311 |
SELECT f1, f2 FROM t1; |
| 312 |
|
| 313 |
--echo # Test End |
| 314 |
--echo # --------------------------------------------------------------- |
| 315 |
--echo # Test Begin: Test if recovery works if 2nd page of |
| 316 |
--echo # system tablespace is corrupted. |
| 317 |
|
| 318 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 319 |
|
| 320 |
SELECT @@innodb_doublewrite; |
| 321 |
SET GLOBAL innodb_doublewrite=ON; |
| 322 |
SELECT @@innodb_doublewrite; |
| 323 |
|
| 324 |
BEGIN; |
| 325 |
INSERT INTO t1 VALUES (6, repeat('%', 400)); |
| 326 |
|
| 327 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 328 |
|
| 329 |
--echo # Make the second page dirty for system tablespace |
| 330 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 331 |
|
| 332 |
# Set the page dirty and force a flush to disk |
| 333 |
--source include/expect_crash.inc |
| 334 |
--error CR_SERVER_LOST |
| 335 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 336 |
|
| 337 |
--echo # Make the 2nd page (page_no=1) of the system tablespace |
| 338 |
--echo # all zeroes. |
| 339 |
--let IBD_FILE=$MYSQLD_DATADIR/ibdata1 |
| 340 |
--let PAGE_NUM=1 |
| 341 |
--source corrupt_page.inc |
| 342 |
|
| 343 |
--let $restart_parameters= |
| 344 |
--source include/start_mysqld.inc |
| 345 |
|
| 346 |
CHECK TABLE t1; |
| 347 |
SELECT f1, f2 FROM t1; |
| 348 |
|
| 349 |
--echo # Test End |
| 350 |
--echo # --------------------------------------------------------------- |
| 351 |
|
| 352 |
DROP TABLE t1; |
| 353 |
|
| 354 |
|