File: innodb_bug14147491.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (98 lines) | stat: -rw-r--r-- 2,737 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#
# Test opening a corrupted table.
#

# Valgrind can hang or return spurious messages on DBUG_SUICIDE
source include/not_valgrind.inc;
# Avoid CrashReporter popup on Mac
source include/not_crashrep.inc;
# Require InnoDB
# Require Debug for SET DEBUG
source include/have_debug.inc;

--disable_query_log
CALL mtr.add_suppression("\\[ERROR\\] .* Unable to read page \\[page id: space=.*, page number=.*\\] into the buffer pool after 100 attempts");
CALL mtr.add_suppression("\\[ERROR\\] .* Database page corruption on disk or a failed");
# ib::fatal() calls ut_error
call mtr.add_suppression("\\[ERROR\\] .* Assertion failure: buf0buf\.cc:[0-9]+:ib::fatal triggered");
--enable_query_log

# Disable compression for this table, otherwise our pattern matching below
# will not work
--echo # Create and populate the table to be corrupted
CREATE TABLE t1 (a INT AUTO_INCREMENT PRIMARY KEY, b TEXT) COMPRESSION="none",
ROW_FORMAT=COMPACT ENGINE=InnoDB;
INSERT INTO t1 (b) VALUES ('corrupt me');
--disable_query_log
--let $i = 10
while ($i)
{
  INSERT INTO t1 (b) VALUES (REPEAT('abcdefghijklmnopqrstuvwxyz', 100));
  dec $i;
}
--enable_query_log
INSERT INTO t1 (b) VALUES ('corrupt me');

let $MYSQLD_DATADIR=`select @@datadir`;
let t1_IBD = $MYSQLD_DATADIR/test/t1.ibd;

--source include/shutdown_mysqld.inc

--echo # Backup the t1.ibd before corrupting
--copy_file $t1_IBD $MYSQLD_DATADIR/test/t1.ibd.backup

--echo # Corrupt the table

perl;
use strict;
use warnings;
use Fcntl qw(:DEFAULT :seek);

my $ibd_file = $ENV{'t1_IBD'};

my $chunk;
my $len;

sysopen IBD_FILE, $ibd_file, O_RDWR || die "Unable to open $ibd_file";

while ($len = sysread IBD_FILE, $chunk, 1024)
{
  if ($chunk =~ s/corrupt me/korrupt me/)
  {
    print "Munged a string.\n";
    sysseek IBD_FILE, -$len, SEEK_CUR;
    syswrite IBD_FILE, $chunk, $len;
  }
}

close IBD_FILE;
EOF

--source include/start_mysqld.inc

SET DEBUG = '+d,innodb_page_corruption_retries';

--echo # Write file to make mysql-test-run.pl expect the "crash", but don't
--echo # start it until it's told to
--exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect

--echo # The below SELECT query will crash the server because some pages
--echo # on the disk are corrupted
--error 2013
SELECT * FROM t1;

# Disconnect all connections to release all locks on t1.ibd file.
--disable_reconnect
--source include/wait_until_disconnected.inc

--echo # Restore the original t1.ibd
--remove_file $MYSQLD_DATADIR/test/t1.ibd
--move_file $MYSQLD_DATADIR/test/t1.ibd.backup $MYSQLD_DATADIR/test/t1.ibd

--source include/start_mysqld.inc

# Note SET DEBUG = '-d,innodb_page_corruption_retries' is not required
# because the session information is lost after server restart

--echo # Cleanup
DROP TABLE t1;