| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_innodb_16k.inc |
| 3 |
# Some operating systems or file systems do not support sparse files. |
| 4 |
# For example, tmpfs on FreeBSD does not support them. |
| 5 |
# On Microsoft Windows, sparse files have to be created in a special way. |
| 6 |
--source include/big_test.inc |
| 7 |
# include/shutdown_mysqld.inc does not work in ./mtr --embedded |
| 8 |
--source include/not_embedded.inc |
| 9 |
|
| 10 |
call mtr.add_suppression("InnoDB: The change buffer is corrupted"); |
| 11 |
|
| 12 |
--source include/shutdown_mysqld.inc |
| 13 |
|
| 14 |
let bugdir= $MYSQLTEST_VARDIR/tmp/log_upgrade; |
| 15 |
--mkdir $bugdir |
| 16 |
--let SEARCH_FILE = $MYSQLTEST_VARDIR/log/mysqld.1.err |
| 17 |
|
| 18 |
--let $dirs= --innodb-data-home-dir=$bugdir --innodb-log-group-home-dir=$bugdir |
| 19 |
|
| 20 |
--echo # |
| 21 |
--echo # MDEV-24412 InnoDB: Upgrade after a crash is not supported |
| 22 |
--echo # |
| 23 |
|
| 24 |
perl; |
| 25 |
do "$ENV{MTR_SUITE_DIR}/../innodb/include/crc32.pl"; |
| 26 |
my $polynomial = 0x82f63b78; # CRC-32C |
| 27 |
|
| 28 |
# Create a dummy system tablespace file using the default innodb_page_size=16k |
| 29 |
die unless open OUT, ">", "$ENV{bugdir}/ibdata1"; |
| 30 |
binmode OUT; |
| 31 |
|
| 32 |
# We calculate innodb_checksum_algorithm=crc32 for the pages. |
| 33 |
# The following bytes are excluded: |
| 34 |
# bytes 0..3 (the checksum is stored there) |
| 35 |
# bytes 26..37 (encryption key version, post-encryption checksum, tablespace id) |
| 36 |
# bytes $page_size-8..$page_size-1 (checksum, LSB of FIL_PAGE_LSN) |
| 37 |
|
| 38 |
# Tablespace header page with valid FSP_SIZE=768 pages. |
| 39 |
# Also, write a dummy FSEG_MAGIC_N at offset 60 to keep fseg_inode_try_get() |
| 40 |
# happy when fseg_n_reserved_pages() is following an invalid pointer |
| 41 |
# from the all-zero change buffer header page (page 3). |
| 42 |
## FIL_PAGE_OFFSET |
| 43 |
my $head = pack("Nx[18]", 0); |
| 44 |
## FSP_PAGE_SIZE, # FSEG_MAGIC_N |
| 45 |
my $body = pack("x[8]Nx[10]Nx[16312]", 768, 97937874); |
| 46 |
my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); |
| 47 |
print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); |
| 48 |
|
| 49 |
# Dummy change buffer header page (page 3). |
| 50 |
die unless seek(OUT, 3 * 16384, 0); |
| 51 |
## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE |
| 52 |
my $head = pack("NNNx[8]n", 3, 0xffffffff, 0xffffffff, 6); |
| 53 |
my $body = pack("x[62]nnx[16272]", 2, 50); |
| 54 |
my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); |
| 55 |
print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); |
| 56 |
|
| 57 |
# Dummy change buffer root page (page 4). |
| 58 |
## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT |
| 59 |
my $head = pack("NNNx[10]", 4, 0xffffffff, 0xffffffff); |
| 60 |
my $body = chr(0) x 16338; |
| 61 |
my $ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); |
| 62 |
print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); |
| 63 |
|
| 64 |
# Dictionary header page (page 7). |
| 65 |
die unless seek(OUT, 7 * 16384, 0); |
| 66 |
## FIL_PAGE_OFFSET |
| 67 |
$head = pack("Nx[18]", 7); |
| 68 |
## DICT_HDR_TABLES,DICT_HDR_INDEXES |
| 69 |
$body = pack("x[32]Nx[8]Nx[16290]", 8, 9); |
| 70 |
$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); |
| 71 |
print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); |
| 72 |
|
| 73 |
# Empty SYS_TABLES page (page 8). |
| 74 |
## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE |
| 75 |
$head = pack("NNNx[8]n", 8, ~0, ~0, 17855); |
| 76 |
## PAGE_N_DIR_SLOTS, PAGE_HEAP_TOP, PAGE_INDEX_ID == DICT_TABLES_ID |
| 77 |
$body = pack("nnx[31]Cx[20]", 2, 124, 1); |
| 78 |
$body .= pack("nxnn", 0x801, 3, 116) . "infimum"; |
| 79 |
$body .= pack("xnxnxx", 0x901, 0x803) . "supremum"; |
| 80 |
$body .= pack("x[16248]nn", 116, 101); |
| 81 |
$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); |
| 82 |
print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); |
| 83 |
|
| 84 |
# Empty SYS_INDEXES page (page 9). |
| 85 |
## FIL_PAGE_OFFSET, FIL_PAGE_PREV, FIL_PAGE_NEXT, FIL_PAGE_TYPE |
| 86 |
$head = pack("NNNx[8]n", 9, ~0, ~0, 17855); |
| 87 |
## PAGE_N_DIR_SLOTS, PAGE_HEAP_TOP, PAGE_INDEX_ID == DICT_INDEXES_ID |
| 88 |
$body = pack("nnx[31]Cx[20]", 2, 124, 3); |
| 89 |
$body .= pack("nxnn", 0x801, 3, 116) . "infimum"; |
| 90 |
$body .= pack("xnxnxx", 0x901, 0x803) . "supremum"; |
| 91 |
$body .= pack("x[16248]nn", 116, 101); |
| 92 |
$ck = mycrc32($head, 0, $polynomial) ^ mycrc32($body, 0, $polynomial); |
| 93 |
print OUT pack("N",$ck).$head.pack("x[12]").$body.pack("Nx[4]",$ck); |
| 94 |
|
| 95 |
die unless seek(OUT, 768 * 16384 - 1, 0); |
| 96 |
print OUT chr(0); |
| 97 |
close OUT or die; |
| 98 |
|
| 99 |
die unless open OUT, ">", "$ENV{bugdir}/ib_logfile0"; |
| 100 |
binmode OUT; |
| 101 |
$_= pack("Nx[5]nx[5]", 1, 0x1286) . "BogoDB 4.3.2.1" . chr(0) x 478; |
| 102 |
print OUT $_, pack("N", mycrc32($_, 0, $polynomial)); |
| 103 |
# checkpoint page 1 and all-zero checkpoint 2 |
| 104 |
$_= pack("x[13]nCNNx[484]", 0x1286, 12, 2, 0x80c); |
| 105 |
print OUT $_, pack("N", mycrc32($_, 0, $polynomial)); |
| 106 |
die unless seek(OUT, 0x1FFFFFFFF, 0); |
| 107 |
print OUT chr(0); |
| 108 |
close OUT or die; |
| 109 |
die unless open OUT, ">", "$ENV{bugdir}/ib_logfile1"; |
| 110 |
binmode OUT; |
| 111 |
die unless seek(OUT, 0x800, 0); # the first 2048 bytes are unused! |
| 112 |
$_= pack("Nnnx[500]", 0x80000944, 12, 12); |
| 113 |
print OUT $_, pack("N", mycrc32($_, 0, $polynomial)); |
| 114 |
die unless seek(OUT, 0x1FFFFFFFF, 0); |
| 115 |
print OUT chr(0); |
| 116 |
close OUT or die; |
| 117 |
EOF |
| 118 |
|
| 119 |
--let $restart_parameters= $dirs --innodb-force-recovery=5 --innodb-log-file-size=4m |
| 120 |
--source include/start_mysqld.inc |
| 121 |
SELECT COUNT(*) FROM INFORMATION_SCHEMA.ENGINES |
| 122 |
WHERE engine = 'innodb' |
| 123 |
AND support IN ('YES', 'DEFAULT', 'ENABLED'); |
| 124 |
--source include/shutdown_mysqld.inc |
| 125 |
--let SEARCH_PATTERN= InnoDB: Upgrading redo log: |
| 126 |
--source include/search_pattern_in_file.inc |
| 127 |
--let $restart_parameters= $dirs |
| 128 |
|
| 129 |
--list_files $bugdir |
| 130 |
--remove_files_wildcard $bugdir |
| 131 |
--rmdir $bugdir |
| 132 |
--let $restart_parameters= |
| 133 |
--source include/start_mysqld.inc |
| 134 |
|
| 135 |
--echo # End of 10.5 tests |