|
| 1 | +# The option innodb_extend_and_initialize cannot be changed on windows |
| 2 | +# where the default is TRUE |
| 3 | +--source include/linux.inc |
| 4 | + |
| 5 | +--source include/have_debug.inc |
| 6 | +--source include/not_valgrind.inc |
| 7 | + |
| 8 | +--let $explicit_default_wait_counter=10000; |
| 9 | + |
| 10 | +# The default value for innodb_extend_and_initialize is TRUE which |
| 11 | +# means the tablespaces will be extended and initialized by writing |
| 12 | +# NULLs to it. |
| 13 | +# Run these tests with the value set to FALSE viz. do not initialize |
| 14 | +# the extended space by writing NULLs to it. |
| 15 | +SET PERSIST innodb_extend_and_initialize=FALSE; |
| 16 | +SELECT @@GLOBAL.innodb_extend_and_initialize; |
| 17 | + |
| 18 | +--echo # Scenario-1: posix_fallocate returns errors EINTR |
| 19 | +--echo # or EINVAL |
| 20 | + |
| 21 | +DROP TABLE IF EXISTS ttext1; |
| 22 | +CREATE TABLE ttext1(c1 INT, c2 TEXT); |
| 23 | + |
| 24 | +INSERT INTO ttext1 VALUES(1, REPEAT('abcdef', 10000)); |
| 25 | +INSERT INTO ttext1 VALUES(2, REPEAT('abcdef', 10000)); |
| 26 | +INSERT INTO ttext1 VALUES(3, REPEAT('abcdef', 10000)); |
| 27 | + |
| 28 | +# Force server to return EINTR error after posix_fallocate |
| 29 | +SET SESSION debug='+d,ib_posix_fallocate_fail_eintr'; |
| 30 | +INSERT INTO ttext1 VALUES(4, REPEAT('abcdef', 10000)); |
| 31 | + |
| 32 | +SELECT COUNT(*) FROM ttext1; |
| 33 | + |
| 34 | +DROP TABLE ttext1; |
| 35 | + |
| 36 | +SET SESSION debug='-d,ib_posix_fallocate_fail_eintr'; |
| 37 | + |
| 38 | +--echo # Scenario-2: Server crashed while creating a table |
| 39 | +--echo # just after writing the redo log record for space |
| 40 | +--echo # extension |
| 41 | + |
| 42 | +DROP TABLE IF EXISTS t1; |
| 43 | + |
| 44 | +# Crash the server just after adding a redo log entry |
| 45 | +# for space expansion |
| 46 | +SET SESSION debug='+d,ib_crash_after_writing_redo_extend_1'; |
| 47 | +--source include/expect_crash.inc |
| 48 | +--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR |
| 49 | +CREATE TABLE t1(a char(1), b char(1), key(a, b)) ENGINE=innodb; |
| 50 | + |
| 51 | +--echo # Restart after the crash |
| 52 | +--source include/start_mysqld_no_echo.inc |
| 53 | + |
| 54 | +--error ER_NO_SUCH_TABLE |
| 55 | +INSERT INTO t1 VALUES('a','b'); |
| 56 | + |
| 57 | +--echo # Scenario-3: Server crashed after writing the redo log |
| 58 | +--echo # but before the transaction could commit |
| 59 | + |
| 60 | +CREATE TABLE ttext1(c1 INT, c2 TEXT); |
| 61 | + |
| 62 | +INSERT INTO ttext1 VALUES(1, REPEAT('abcdef',10000)); |
| 63 | +INSERT INTO ttext1 VALUES(2, REPEAT('abcdef',10000)); |
| 64 | +INSERT INTO ttext1 VALUES(3, REPEAT('abcdef',10000)); |
| 65 | + |
| 66 | +# Crash the server just after adding a redo log entry |
| 67 | +# for space expansion |
| 68 | +SET SESSION debug='+d,ib_crash_after_writing_redo_extend_1'; |
| 69 | +--source include/expect_crash.inc |
| 70 | +--error 0,CR_SERVER_LOST,ER_INTERNAL_ERROR |
| 71 | +INSERT INTO ttext1 VALUES(4, REPEAT('abcdef',10000)); |
| 72 | + |
| 73 | +--echo # Restart after the crash |
| 74 | +--source include/start_mysqld_no_echo.inc |
| 75 | + |
| 76 | +SELECT COUNT(*) FROM ttext1; |
| 77 | + |
| 78 | +# Insert few more rows into the table |
| 79 | +INSERT INTO ttext1 VALUES(5, REPEAT('abcdef',10000)); |
| 80 | +INSERT INTO ttext1 VALUES(6, REPEAT('abcdef',10000)); |
| 81 | + |
| 82 | +SELECT COUNT(*) FROM ttext1; |
| 83 | + |
| 84 | +# Cleanup |
| 85 | +DROP TABLE ttext1; |
| 86 | + |
| 87 | +SET PERSIST innodb_extend_and_initialize=DEFAULT; |
| 88 | +SELECT @@GLOBAL.innodb_extend_and_initialize; |
| 89 | + |
| 90 | +--echo # Scenario-4: Server crashes before the checkpoint |
| 91 | + |
| 92 | +# Disable the checkpoint |
| 93 | +SET @@GLOBAL.INNODB_CHECKPOINT_DISABLED='ON'; |
| 94 | + |
| 95 | +DROP TABLE IF EXISTS ttext; |
| 96 | +CREATE TABLE ttext(c1 INT, c2 TEXT); |
| 97 | + |
| 98 | +# Insert few rows to create some redo logs for space extension |
| 99 | +INSERT INTO ttext VALUES(1, REPEAT('abcdef',10000)); |
| 100 | +INSERT INTO ttext VALUES(2, REPEAT('abcdef',10000)); |
| 101 | +INSERT INTO ttext VALUES(3, REPEAT('abcdef',10000)); |
| 102 | +INSERT INTO ttext VALUES(4, REPEAT('abcdef',10000)); |
| 103 | +SELECT COUNT(*) FROM ttext; |
| 104 | + |
| 105 | +# Kill and restart the server |
| 106 | +--source include/kill_and_restart_mysqld.inc |
| 107 | + |
| 108 | +# Validate that the checkpoints are not disabled |
| 109 | +SELECT @@GLOBAL.INNODB_CHECKPOINT_DISABLED; |
| 110 | + |
| 111 | +SELECT @@GLOBAL.innodb_extend_and_initialize; |
| 112 | + |
| 113 | +SELECT COUNT(*) FROM ttext; |
| 114 | + |
| 115 | +DROP TABLE ttext; |
| 116 | + |
| 117 | +SET PERSIST innodb_extend_and_initialize=DEFAULT; |
| 118 | +SELECT @@GLOBAL.innodb_extend_and_initialize; |
| 119 | + |
| 120 | +--echo # Scenario-5: Server crasheѕ before checkpoint |
| 121 | +--echo # and restarted with innodb_extend_and_initialize=off |
| 122 | + |
| 123 | +SET @@GLOBAL.innodb_extend_and_initialize='OFF'; |
| 124 | +SELECT @@GLOBAL.innodb_extend_and_initialize; |
| 125 | + |
| 126 | +# Disable the checkpoint |
| 127 | +SET @@GLOBAL.INNODB_CHECKPOINT_DISABLED='ON'; |
| 128 | + |
| 129 | +CREATE TABLE ttext(c1 INT, c2 TEXT); |
| 130 | + |
| 131 | +# Insert few rows to create some redo logs for space extension |
| 132 | +INSERT INTO ttext VALUES(1, REPEAT('abcdef',10000)); |
| 133 | +INSERT INTO ttext VALUES(2, REPEAT('abcdef',10000)); |
| 134 | +INSERT INTO ttext VALUES(3, REPEAT('abcdef',10000)); |
| 135 | +INSERT INTO ttext VALUES(4, REPEAT('abcdef',10000)); |
| 136 | +SELECT COUNT(*) FROM ttext; |
| 137 | + |
| 138 | +# Kill and restart the server |
| 139 | +--source include/kill_and_restart_mysqld.inc |
| 140 | + |
| 141 | +# Validate that the checkpoints are not disabled |
| 142 | +SELECT @@GLOBAL.INNODB_CHECKPOINT_DISABLED; |
| 143 | +SELECT @@GLOBAL.innodb_extend_and_initialize; |
| 144 | + |
| 145 | +SELECT COUNT(*) FROM ttext; |
| 146 | + |
| 147 | +DROP TABLE ttext; |
| 148 | + |
| 149 | +RESET PERSIST; |
0 commit comments