| 1 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 2 |
Variable_name Value |
| 3 |
innodb_doublewrite ON |
| 4 |
SHOW VARIABLES LIKE 'innodb_fil_make_page_dirty_debug'; |
| 5 |
Variable_name Value |
| 6 |
innodb_fil_make_page_dirty_debug 4294967295 |
| 7 |
SHOW VARIABLES LIKE 'innodb_saved_page_number_debug'; |
| 8 |
Variable_name Value |
| 9 |
innodb_saved_page_number_debug 0 |
| 10 |
# Wait for purge to complete |
| 11 |
create table t1 (f1 int primary key, f2 blob) engine=innodb STATS_PERSISTENT=0; |
| 12 |
START TRANSACTION; |
| 13 |
INSERT INTO t1 VALUES(1, repeat('#',12)); |
| 14 |
INSERT INTO t1 VALUES(2, repeat('+',12)); |
| 15 |
INSERT INTO t1 VALUES(3, repeat('/',12)); |
| 16 |
INSERT INTO t1 VALUES(4, repeat('-',12)); |
| 17 |
INSERT INTO t1 VALUES(5, repeat('.',12)); |
| 18 |
COMMIT WORK; |
| 19 |
SET GLOBAL innodb_fast_shutdown = 0; |
| 20 |
# Take backup of original datadir |
| 21 |
# restart: --datadir=BACKUP/data |
| 22 |
# --------------------------------------------------------------- |
| 23 |
# Test Begin: Test if recovery works if first page of user |
| 24 |
# tablespace is full of zeroes. |
| 25 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 26 |
Variable_name Value |
| 27 |
innodb_doublewrite ON |
| 28 |
# Ensure that dirty pages of table t1 is flushed. |
| 29 |
FLUSH TABLES t1 FOR EXPORT; |
| 30 |
UNLOCK TABLES; |
| 31 |
SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACEs |
| 32 |
WHERE name = 'test/t1' INTO @space_id; |
| 33 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 34 |
SET GLOBAL innodb_limit_optimistic_insert_debug=2; |
| 35 |
SELECT @@innodb_doublewrite; |
| 36 |
@@innodb_doublewrite |
| 37 |
ON |
| 38 |
BEGIN; |
| 39 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 40 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 41 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 42 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 43 |
COMMIT; |
| 44 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 45 |
SELECT @@innodb_doublewrite; |
| 46 |
@@innodb_doublewrite |
| 47 |
DETECT_ONLY |
| 48 |
BEGIN; |
| 49 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 50 |
INSERT INTO t1 SELECT f1+64,f2 FROM t1; |
| 51 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 52 |
# Make the first page dirty for table t1 |
| 53 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 54 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 55 |
ERROR HY000: Lost connection to MySQL server during query |
| 56 |
# Make the first page (page_no=0) of the user tablespace |
| 57 |
# full of zeroes. |
| 58 |
# restoring original datadir |
| 59 |
# restart: --datadir=BACKUP/data |
| 60 |
# Test End - 1 |
| 61 |
# --------------------------------------------------------------- |
| 62 |
# Test Begin: Test if recovery works if first page of user |
| 63 |
# tablespace is corrupted. |
| 64 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 65 |
Variable_name Value |
| 66 |
innodb_doublewrite ON |
| 67 |
SELECT space from INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 68 |
WHERE name = 'test/t1' INTO @space_id; |
| 69 |
# Ensure that dirty pages of table t1 is flushed. |
| 70 |
FLUSH TABLES t1 FOR EXPORT; |
| 71 |
UNLOCK TABLES; |
| 72 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 73 |
SELECT @@innodb_doublewrite; |
| 74 |
@@innodb_doublewrite |
| 75 |
ON |
| 76 |
BEGIN; |
| 77 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 78 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 79 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 80 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 81 |
COMMIT; |
| 82 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 83 |
SELECT @@innodb_doublewrite; |
| 84 |
@@innodb_doublewrite |
| 85 |
DETECT_ONLY |
| 86 |
BEGIN; |
| 87 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 88 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 89 |
# Make the first page dirty for table t1 |
| 90 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 91 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 92 |
ERROR HY000: Lost connection to MySQL server during query |
| 93 |
# Corrupt the first page (page_no=0) of the user tablespace. |
| 94 |
# restoring original datadir |
| 95 |
# restart: --datadir=BACKUP/data |
| 96 |
# Test End - 2 |
| 97 |
# --------------------------------------------------------------- |
| 98 |
# Test Begin: Test if recovery works if 2nd page of user |
| 99 |
# tablespace is full of zeroes. |
| 100 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 101 |
Variable_name Value |
| 102 |
innodb_doublewrite ON |
| 103 |
SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 104 |
WHERE name = 'test/t1' INTO @space_id; |
| 105 |
# Ensure that dirty pages of table t1 is flushed. |
| 106 |
FLUSH TABLES t1 FOR EXPORT; |
| 107 |
UNLOCK TABLES; |
| 108 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 109 |
SELECT @@innodb_doublewrite; |
| 110 |
@@innodb_doublewrite |
| 111 |
ON |
| 112 |
BEGIN; |
| 113 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 114 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 115 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 116 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 117 |
COMMIT; |
| 118 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 119 |
SELECT @@innodb_doublewrite; |
| 120 |
@@innodb_doublewrite |
| 121 |
DETECT_ONLY |
| 122 |
BEGIN; |
| 123 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 124 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 125 |
# Make the 2nd page dirty for table t1 |
| 126 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 127 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 128 |
ERROR HY000: Lost connection to MySQL server during query |
| 129 |
# Make the 2nd page (page_no=1) of the tablespace all zeroes. |
| 130 |
# restoring original datadir |
| 131 |
# restart: --datadir=BACKUP/data |
| 132 |
# Test End - 3 |
| 133 |
# --------------------------------------------------------------- |
| 134 |
# Test Begin: Test if recovery works if 2nd page of user |
| 135 |
# tablespace is corrupted. |
| 136 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 137 |
Variable_name Value |
| 138 |
innodb_doublewrite ON |
| 139 |
SELECT space FROM INFORMATION_SCHEMA.INNODB_TABLESPACES |
| 140 |
WHERE name = 'test/t1' into @space_id; |
| 141 |
FLUSH TABLES t1 FOR EXPORT; |
| 142 |
UNLOCK TABLES; |
| 143 |
SET GLOBAL innodb_checkpoint_disabled=1; |
| 144 |
SELECT @@innodb_doublewrite; |
| 145 |
@@innodb_doublewrite |
| 146 |
ON |
| 147 |
BEGIN; |
| 148 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 149 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 150 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 151 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 152 |
COMMIT; |
| 153 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 154 |
SELECT @@innodb_doublewrite; |
| 155 |
@@innodb_doublewrite |
| 156 |
DETECT_ONLY |
| 157 |
BEGIN; |
| 158 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 159 |
# Make the 2nd page dirty for table t1 |
| 160 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 161 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 162 |
SET GLOBAL innodb_fil_make_page_dirty_debug = @space_id; |
| 163 |
ERROR HY000: Lost connection to MySQL server during query |
| 164 |
# Corrupt the 2nd page (page_no=1) of the user tablespace. |
| 165 |
# restoring original datadir |
| 166 |
# restart: --datadir=BACKUP/data |
| 167 |
# Test End - 4 |
| 168 |
# --------------------------------------------------------------- |
| 169 |
# Test Begin: Test if recovery works if first page of |
| 170 |
# system tablespace is full of zeroes. |
| 171 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 172 |
Variable_name Value |
| 173 |
innodb_doublewrite ON |
| 174 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 175 |
SELECT @@innodb_doublewrite; |
| 176 |
@@innodb_doublewrite |
| 177 |
ON |
| 178 |
BEGIN; |
| 179 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 180 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 181 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 182 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 183 |
COMMIT; |
| 184 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 185 |
SELECT @@innodb_doublewrite; |
| 186 |
@@innodb_doublewrite |
| 187 |
DETECT_ONLY |
| 188 |
BEGIN; |
| 189 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 190 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 191 |
# Make the first page dirty for system tablespace |
| 192 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 193 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 194 |
ERROR HY000: Lost connection to MySQL server during query |
| 195 |
# Make the first page (page_no=0) of the system tablespace |
| 196 |
# all zeroes. |
| 197 |
# restoring original datadir |
| 198 |
# restart: --datadir=BACKUP/data |
| 199 |
# Test End - 5 |
| 200 |
# --------------------------------------------------------------- |
| 201 |
# Test Begin: Test if recovery works if first page of |
| 202 |
# system tablespace is corrupted. |
| 203 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 204 |
Variable_name Value |
| 205 |
innodb_doublewrite ON |
| 206 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 207 |
SELECT @@innodb_doublewrite; |
| 208 |
@@innodb_doublewrite |
| 209 |
ON |
| 210 |
BEGIN; |
| 211 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 212 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 213 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 214 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 215 |
COMMIT; |
| 216 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 217 |
SELECT @@innodb_doublewrite; |
| 218 |
@@innodb_doublewrite |
| 219 |
DETECT_ONLY |
| 220 |
BEGIN; |
| 221 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 222 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 223 |
# Make the first page dirty for system tablespace |
| 224 |
SET GLOBAL innodb_saved_page_number_debug = 0; |
| 225 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 226 |
ERROR HY000: Lost connection to MySQL server during query |
| 227 |
# Corrupt the first page (page_no=0) of the system tablespace. |
| 228 |
# restoring original datadir |
| 229 |
# restart: --datadir=BACKUP/data |
| 230 |
# Test End - 6 |
| 231 |
# --------------------------------------------------------------- |
| 232 |
# Test Begin: Test if recovery works if 2nd page of |
| 233 |
# system tablespace is full of zeroes. |
| 234 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 235 |
Variable_name Value |
| 236 |
innodb_doublewrite ON |
| 237 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 238 |
SELECT @@innodb_doublewrite; |
| 239 |
@@innodb_doublewrite |
| 240 |
ON |
| 241 |
BEGIN; |
| 242 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 243 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 244 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 245 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 246 |
COMMIT; |
| 247 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 248 |
SELECT @@innodb_doublewrite; |
| 249 |
@@innodb_doublewrite |
| 250 |
DETECT_ONLY |
| 251 |
BEGIN; |
| 252 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 253 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 254 |
# Make the second page dirty for system tablespace |
| 255 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 256 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 257 |
ERROR HY000: Lost connection to MySQL server during query |
| 258 |
# Make the 2nd page (page_no=1) of the system tablespace |
| 259 |
# all zeroes. |
| 260 |
# restoring original datadir |
| 261 |
# restart: --datadir=BACKUP/data |
| 262 |
# Test End - 7 |
| 263 |
# --------------------------------------------------------------- |
| 264 |
# Test Begin: Test if recovery works if 2nd page of |
| 265 |
# system tablespace is corrupted. |
| 266 |
SHOW VARIABLES LIKE 'innodb_doublewrite'; |
| 267 |
Variable_name Value |
| 268 |
innodb_doublewrite ON |
| 269 |
SET GLOBAL innodb_master_thread_disabled_debug=1; |
| 270 |
SELECT @@innodb_doublewrite; |
| 271 |
@@innodb_doublewrite |
| 272 |
ON |
| 273 |
BEGIN; |
| 274 |
INSERT INTO t1 VALUES (6, repeat('%', 12)); |
| 275 |
INSERT INTO t1 SELECT f1+8,f2 FROM t1; |
| 276 |
INSERT INTO t1 SELECT f1+16,f2 FROM t1; |
| 277 |
INSERT INTO t1 SELECT f1+32,f2 FROM t1; |
| 278 |
COMMIT; |
| 279 |
SET GLOBAL innodb_doublewrite=detect_only; |
| 280 |
SELECT @@innodb_doublewrite; |
| 281 |
@@innodb_doublewrite |
| 282 |
DETECT_ONLY |
| 283 |
BEGIN; |
| 284 |
INSERT INTO t1 VALUES (0, repeat('%', 12)); |
| 285 |
SET GLOBAL innodb_checkpoint_disabled = 1; |
| 286 |
# Make the second page dirty for system tablespace |
| 287 |
SET GLOBAL innodb_saved_page_number_debug = 1; |
| 288 |
SET GLOBAL innodb_fil_make_page_dirty_debug = 0; |
| 289 |
ERROR HY000: Lost connection to MySQL server during query |
| 290 |
# Make the 2nd page (page_no=1) of the system tablespace |
| 291 |
# all zeroes. |
| 292 |
# restoring original datadir |
| 293 |
# restart |
| 294 |
# Test End - 8 |
| 295 |
# --------------------------------------------------------------- |
| 296 |
DROP TABLE t1; |