Debian Codegraph @

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

raw
1 --source include/have_innodb.inc
2 # The embedded server does not support restarting in mysql-test-run.
3 -- source include/not_embedded.inc
4 -- source include/no_valgrind_without_big.inc
5 -- source include/innodb_checksum_algorithm.inc
6
7 let MYSQLD_DATADIR=`select @@datadir`;
8 let PAGE_SIZE=`select @@innodb_page_size`;
9
10 SELECT @@innodb_doublewrite;
11 SET GLOBAL innodb_doublewrite=fast;
12
13 -- disable_query_log
14 call mtr.add_suppression("InnoDB: innodb_force_recovery is on.");
15 call mtr.add_suppression("InnoDB: Ignoring tablespace for.*bug16720368");
16 call mtr.add_suppression("Found 1 prepared XA transactions");
17 call mtr.add_suppression("InnoDB: Operating system error.*in a file operation");
18 call mtr.add_suppression("InnoDB: \(The error means\|If you are\)");
19 call mtr.add_suppression("InnoDB: Ignoring tablespace `test/bug16720368` because it could not be opened");
20 call mtr.add_suppression("InnoDB: Tablespace .* was not found at.*bug16735660");
21 call mtr.add_suppression("InnoDB: Plugin initialization aborted*");
22 call mtr.add_suppression("Plugin 'InnoDB' init function returned error.");
23 call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed.");
24 call mtr.add_suppression("Fewer engines are enabled now than were before the crash");
25 call mtr.add_suppression("Table .*bug16720368.* is corrupted");
26 -- enable_query_log
27
28 -- echo #
29 -- echo # Bug#16720368 INNODB CRASHES ON BROKEN #SQL*.IBD FILE AT STARTUP
30 -- echo #
31
32 SET GLOBAL innodb_stats_persistent=0;
33
34 CREATE TABLE bug16720368_1 (a INT PRIMARY KEY) ENGINE=InnoDB;
35
36 connect (con1,localhost,root);
37 CREATE TABLE bug16720368 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
38 INSERT INTO bug16720368 (a) VALUES (1),(2),(3),(4),(5),(6),(7),(8);
39 --source include/wait_all_purged.inc
40
41 connection default;
42
43 -- echo # Cleanly shutdown mysqld
44 -- source include/shutdown_mysqld.inc
45
46 disconnect con1;
47
48 -- echo # Corrupt FIL_PAGE_TYPE in bug16720368.ibd,
49 -- echo # and recompute innodb_checksum_algorithm=crc32
50 perl;
51 do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
52 my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd";
53 open(FILE, "+<$file") || die "Unable to open $file";
54 binmode FILE;
55 my $ps= $ENV{PAGE_SIZE};
56 my $page;
57 die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
58 my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS
59 sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
60 die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
61 substr($page,24,2)='42';
62 my $polynomial = 0x82f63b78; # CRC-32C
63 if ($full_crc32)
64 {
65 my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial);
66 substr($page, $ps-4, 4) = pack("N", $ck);
67 }
68 else
69 {
70 my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
71 mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
72 substr($page,0,4)=$ck;
73 substr($page,$ps-8,4)=$ck;
74 }
75 sysseek(FILE, 3*$ps, 0) || die "Unable to rewind $file\n";
76 syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
77 close(FILE) || die "Unable to close $file";
78 EOF
79
80 -- let $restart_parameters=--innodb-flush-method=O_DIRECT
81 -- source include/start_mysqld.inc
82 -- let $restart_parameters=
83
84 SELECT @@innodb_doublewrite;
85 --error ER_TABLE_CORRUPT
86 SELECT COUNT(*) FROM bug16720368;
87 --error ER_TABLE_CORRUPT
88 INSERT INTO bug16720368 VALUES(1);
89 INSERT INTO bug16720368_1 VALUES(1);
90
91 -- echo # Shut down the server to uncorrupt the data.
92 -- source include/shutdown_mysqld.inc
93
94 # Uncorrupt the FIL_PAGE_TYPE.
95 perl;
96 do "$ENV{MTR_SUITE_DIR}/include/crc32.pl";
97 my $file = "$ENV{MYSQLD_DATADIR}/test/bug16720368.ibd";
98 open(FILE, "+<$file") || die "Unable to open $file";
99 binmode FILE;
100 my $ps= $ENV{PAGE_SIZE};
101 my $page;
102 die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
103 my $full_crc32 = unpack("N",substr($page,54,4)) & 0x10; # FIL_SPACE_FLAGS
104 sysseek(FILE, 3*$ps, 0) || die "Unable to seek $file\n";
105 die "Unable to read $file" unless sysread(FILE, $page, $ps) == $ps;
106 substr($page,24,2)=pack("H*","45BF");
107 my $polynomial = 0x82f63b78; # CRC-32C
108 if ($full_crc32)
109 {
110 my $ck = mycrc32(substr($page, 0, $ps-4), 0, $polynomial);
111 substr($page, $ps-4, 4) = pack("N", $ck);
112 }
113 else
114 {
115 my $ck= pack("N",mycrc32(substr($page, 4, 22), 0, $polynomial) ^
116 mycrc32(substr($page, 38, $ps - 38 - 8), 0, $polynomial));
117 substr($page,0,4)=$ck;
118 substr($page,$ps-8,4)=$ck;
119 }
120 sysseek(FILE, 3*$ps, 0) || die "Unable to rewind $file\n";
121 syswrite(FILE, $page, $ps)==$ps || die "Unable to write $file\n";
122 close(FILE) || die "Unable to close $file";
123 EOF
124
125 -- source include/start_mysqld.inc
126
127 INSERT INTO bug16720368 VALUES(9,1);
128 SELECT COUNT(*) FROM bug16720368;
129 # A debug assertion would fail in buf_block_align_instance()
130 # if we did not uncorrupt the page number first.
131 DROP TABLE bug16720368, bug16720368_1;
132
133 -- echo #
134 -- echo # Bug#16735660 ASSERT TABLE2 == NULL, ROLLBACK OF RESURRECTED TXNS,
135 -- echo # DICT_TABLE_ADD_TO_CACHE
136 -- echo #
137
138 CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB;
139 BEGIN;
140 INSERT INTO t1 VALUES(42);
141
142 -- connect (con1,localhost,root)
143
144 CREATE TABLE bug16735660 (a INT PRIMARY KEY) ENGINE=InnoDB;
145
146 # Force a log checkpoint to "discard" any FILE_CREATE records.
147 SET GLOBAL innodb_max_purge_lag_wait=2;
148 SET GLOBAL innodb_max_dirty_pages_pct_lwm=0.0;
149 SET GLOBAL innodb_max_dirty_pages_pct=0.0;
150 let $wait_condition =
151 SELECT variable_value = 0
152 FROM information_schema.global_status
153 WHERE variable_name = 'INNODB_BUFFER_POOL_PAGES_DIRTY';
154 --source include/wait_condition.inc
155 SET GLOBAL innodb_max_dirty_pages_pct=90.0;
156
157 XA START 'x';
158 --source ../include/no_checkpoint_start.inc
159 INSERT INTO bug16735660 VALUES(1),(2),(3);
160 XA END 'x';
161 XA PREPARE 'x';
162 --connection default
163 --let CLEANUP_IF_CHECKPOINT=XA ROLLBACK 'x';DROP TABLE bug16735660;
164 --source ../include/no_checkpoint_end.inc
165
166 -- disconnect con1
167 -- move_file $MYSQLD_DATADIR/test/bug16735660.ibd $MYSQLD_DATADIR/bug16735660.omg
168
169 -- echo # Attempt to start without an *.ibd file.
170 let SEARCH_FILE= $MYSQLTEST_VARDIR/log/mysqld.1.err;
171 --source include/start_mysqld.inc
172
173 let SEARCH_PATTERN= \[ERROR\] InnoDB: Tablespace [0-9]+ was not found at .*test.bug16735660.ibd;
174 -- source include/search_pattern_in_file.inc
175
176 -- move_file $MYSQLD_DATADIR/bug16735660.omg $MYSQLD_DATADIR/test/bug16735660.ibd
177
178 -- source include/restart_mysqld.inc
179
180 SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED;
181 --disable_ps2_protocol
182 SELECT * FROM bug16735660;
183 --enable_ps2_protocol
184
185 XA RECOVER;
186 XA ROLLBACK 'x';
187
188 --disable_ps2_protocol
189 SELECT * FROM bug16735660;
190 --enable_ps2_protocol
191 DROP TABLE bug16735660;