File: trx_id_future.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 (63 lines) | stat: -rw-r--r-- 1,780 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
--echo #
--echo # Bug #20445525	ADD A CONSISTENCY CHECK AGAINST DB_TRX_ID BEING
--echo #		IN THE FUTURE
--echo #

--source include/have_nodebug.inc

let PAGE_SIZE=`select @@innodb_page_size`;

CREATE TABLE t1(a INT) row_format=redundant engine=innoDB;
INSERT INTO t1 VALUES(1);

let MYSQLD_DATADIR=`select @@datadir`;

--source include/shutdown_mysqld.inc

perl;

$page_size=$ENV{PAGE_SIZE};

my $file = "$ENV{MYSQLD_DATADIR}/test/t1.ibd";
open(FILE, "+<", $file) || die "Unable to open $file";

#Seek the the infimum record and get the offset to next record
#Infimum record exist at offset 101 for redundant format
#And offset to the next record is present 2 bytes prior to
#infimum record

seek(FILE, 4*$page_size+101-2, 0) || die "Unable to seek $file";
die unless read(FILE, $_, 2) == 2;
my $record_offset  =  unpack("n*", $_);

#In this case the first record should be at offset 135
die unless $record_offset == 135;

my $trx_id_of_rec = 4*$page_size + $record_offset + 6;

# Modify DB_TRX_ID of the record to a value which is greater than
# max_trx_id
seek(FILE, $trx_id_of_rec , 0) || die "Unable to seek $file";

my $corrupted_trx_id = "\xff" x 6;
syswrite(FILE, $corrupted_trx_id) || die "Unable to write";

#Modify the checksums of the page

seek(FILE, 4*$page_size, 0) || die "Unable to seek $file";
syswrite(FILE, pack("H*","deadbeef",4)) || die "Unable to write";

seek(FILE, 5*$page_size-8, 0) || die "Unable to seek $file";
syswrite(FILE, pack("H*","deadbeef",4)) || die "Unable to write";

close(FILE)
EOF

--source include/start_mysqld.inc

--disable_query_log
call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* A transaction id in a record of table `\.\.*`\.`\.\.*` is newer than the system-wide maximum.");
--enable_query_log

SELECT * FROM t1;
DROP TABLE t1;