Skip to content

Commit 7687623

Browse files
author
Rahul Agarkar
committed
WL#13782: Add config option to use fallocate() on Linux
This WL introduces a boolean server synamic variable innodb_extend_and_initialize. - Added innodb_extend_and_initialize server variable. This variable can be set to false to make InnoDB skip initializing the newly allocated pages by writing zeroes to them - Added mtr tests to test the functionality - Added sys_vars test case for the new variable RB: 23888 Reviewed by: Pawel Olchawa (pawel.olchawa@oracle.com) Sunny Bains (sunny.bains@oracle.com)
1 parent dd70dec commit 7687623

27 files changed

+994
-47
lines changed

mysql-test/r/all_persisted_variables.result

+5-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* available on all platforms.
44
***********************************************************************
55
call mtr.add_suppression("Failed to set up SSL because of the following SSL library error");
6+
call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* Changing innodb_extend_and_initialize not supported on this platform.");
67
call mtr.add_suppression("Failed to initialize TLS for channel: mysql_main");
78
***************************************************************
89
* 0. Verify that variables present in performance_schema.global
@@ -38,17 +39,17 @@ include/assert.inc [Expect 500+ variables in the table. Due to open Bugs, we are
3839

3940
# Test SET PERSIST
4041

41-
include/assert.inc [Expect 407 persisted variables in the table.]
42+
include/assert.inc [Expect 408 persisted variables in the table.]
4243

4344
************************************************************
4445
* 3. Restart server, it must preserve the persisted variable
4546
* settings. Verify persisted configuration.
4647
************************************************************
4748
# restart
4849

49-
include/assert.inc [Expect 407 persisted variables in persisted_variables table.]
50-
include/assert.inc [Expect 407 persisted variables shown as PERSISTED in variables_info table.]
51-
include/assert.inc [Expect 407 persisted variables with matching peristed and global values.]
50+
include/assert.inc [Expect 408 persisted variables in persisted_variables table.]
51+
include/assert.inc [Expect 408 persisted variables shown as PERSISTED in variables_info table.]
52+
include/assert.inc [Expect 408 persisted variables with matching peristed and global values.]
5253

5354
************************************************************
5455
* 4. Test RESET PERSIST IF EXISTS. Verify persisted variable
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
SET PERSIST innodb_extend_and_initialize=FALSE;
2+
SELECT @@GLOBAL.innodb_extend_and_initialize;
3+
@@GLOBAL.innodb_extend_and_initialize
4+
0
5+
# Scenario-1: posix_fallocate returns errors EINTR
6+
# or EINVAL
7+
DROP TABLE IF EXISTS ttext1;
8+
Warnings:
9+
Note 1051 Unknown table 'test.ttext1'
10+
CREATE TABLE ttext1(c1 INT, c2 TEXT);
11+
INSERT INTO ttext1 VALUES(1, REPEAT('abcdef', 10000));
12+
INSERT INTO ttext1 VALUES(2, REPEAT('abcdef', 10000));
13+
INSERT INTO ttext1 VALUES(3, REPEAT('abcdef', 10000));
14+
SET SESSION debug='+d,ib_posix_fallocate_fail_eintr';
15+
INSERT INTO ttext1 VALUES(4, REPEAT('abcdef', 10000));
16+
SELECT COUNT(*) FROM ttext1;
17+
COUNT(*)
18+
4
19+
DROP TABLE ttext1;
20+
SET SESSION debug='-d,ib_posix_fallocate_fail_eintr';
21+
# Scenario-2: Server crashed while creating a table
22+
# just after writing the redo log record for space
23+
# extension
24+
DROP TABLE IF EXISTS t1;
25+
Warnings:
26+
Note 1051 Unknown table 'test.t1'
27+
SET SESSION debug='+d,ib_crash_after_writing_redo_extend_1';
28+
CREATE TABLE t1(a char(1), b char(1), key(a, b)) ENGINE=innodb;
29+
# Restart after the crash
30+
INSERT INTO t1 VALUES('a','b');
31+
ERROR 42S02: Table 'test.t1' doesn't exist
32+
# Scenario-3: Server crashed after writing the redo log
33+
# but before the transaction could commit
34+
CREATE TABLE ttext1(c1 INT, c2 TEXT);
35+
INSERT INTO ttext1 VALUES(1, REPEAT('abcdef',10000));
36+
INSERT INTO ttext1 VALUES(2, REPEAT('abcdef',10000));
37+
INSERT INTO ttext1 VALUES(3, REPEAT('abcdef',10000));
38+
SET SESSION debug='+d,ib_crash_after_writing_redo_extend_1';
39+
INSERT INTO ttext1 VALUES(4, REPEAT('abcdef',10000));
40+
# Restart after the crash
41+
SELECT COUNT(*) FROM ttext1;
42+
COUNT(*)
43+
3
44+
INSERT INTO ttext1 VALUES(5, REPEAT('abcdef',10000));
45+
INSERT INTO ttext1 VALUES(6, REPEAT('abcdef',10000));
46+
SELECT COUNT(*) FROM ttext1;
47+
COUNT(*)
48+
5
49+
DROP TABLE ttext1;
50+
SET PERSIST innodb_extend_and_initialize=DEFAULT;
51+
SELECT @@GLOBAL.innodb_extend_and_initialize;
52+
@@GLOBAL.innodb_extend_and_initialize
53+
1
54+
# Scenario-4: Server crashes before the checkpoint
55+
SET @@GLOBAL.INNODB_CHECKPOINT_DISABLED='ON';
56+
DROP TABLE IF EXISTS ttext;
57+
Warnings:
58+
Note 1051 Unknown table 'test.ttext'
59+
CREATE TABLE ttext(c1 INT, c2 TEXT);
60+
INSERT INTO ttext VALUES(1, REPEAT('abcdef',10000));
61+
INSERT INTO ttext VALUES(2, REPEAT('abcdef',10000));
62+
INSERT INTO ttext VALUES(3, REPEAT('abcdef',10000));
63+
INSERT INTO ttext VALUES(4, REPEAT('abcdef',10000));
64+
SELECT COUNT(*) FROM ttext;
65+
COUNT(*)
66+
4
67+
# Kill and restart
68+
SELECT @@GLOBAL.INNODB_CHECKPOINT_DISABLED;
69+
@@GLOBAL.INNODB_CHECKPOINT_DISABLED
70+
0
71+
SELECT @@GLOBAL.innodb_extend_and_initialize;
72+
@@GLOBAL.innodb_extend_and_initialize
73+
1
74+
SELECT COUNT(*) FROM ttext;
75+
COUNT(*)
76+
4
77+
DROP TABLE ttext;
78+
SET PERSIST innodb_extend_and_initialize=DEFAULT;
79+
SELECT @@GLOBAL.innodb_extend_and_initialize;
80+
@@GLOBAL.innodb_extend_and_initialize
81+
1
82+
# Scenario-5: Server crasheѕ before checkpoint
83+
# and restarted with innodb_extend_and_initialize=off
84+
SET @@GLOBAL.innodb_extend_and_initialize='OFF';
85+
SELECT @@GLOBAL.innodb_extend_and_initialize;
86+
@@GLOBAL.innodb_extend_and_initialize
87+
0
88+
SET @@GLOBAL.INNODB_CHECKPOINT_DISABLED='ON';
89+
CREATE TABLE ttext(c1 INT, c2 TEXT);
90+
INSERT INTO ttext VALUES(1, REPEAT('abcdef',10000));
91+
INSERT INTO ttext VALUES(2, REPEAT('abcdef',10000));
92+
INSERT INTO ttext VALUES(3, REPEAT('abcdef',10000));
93+
INSERT INTO ttext VALUES(4, REPEAT('abcdef',10000));
94+
SELECT COUNT(*) FROM ttext;
95+
COUNT(*)
96+
4
97+
# Kill and restart
98+
SELECT @@GLOBAL.INNODB_CHECKPOINT_DISABLED;
99+
@@GLOBAL.INNODB_CHECKPOINT_DISABLED
100+
0
101+
SELECT @@GLOBAL.innodb_extend_and_initialize;
102+
@@GLOBAL.innodb_extend_and_initialize
103+
1
104+
SELECT COUNT(*) FROM ttext;
105+
COUNT(*)
106+
4
107+
DROP TABLE ttext;
108+
RESET PERSIST;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* Changing innodb_extend_and_initialize not supported on this platform. Falling back to the default.");
2+
SELECT @@GLOBAL.INNODB_EXTEND_AND_INITIALIZE;
3+
@@GLOBAL.INNODB_EXTEND_AND_INITIALIZE
4+
1
5+
select @@global.innodb_extend_and_initialize;
6+
@@global.innodb_extend_and_initialize
7+
1
8+
SET @@GLOBAL.INNODB_EXTEND_AND_INITIALIZE = FALSE;
9+
Warnings:
10+
Warning 3996 Changing innodb_extend_and_initialize not supported on this platform. Falling back to the default.
11+
select @@global.innodb_extend_and_initialize;
12+
@@global.innodb_extend_and_initialize
13+
1
14+
SET PERSIST INNODB_EXTEND_AND_INITIALIZE = FALSE;
15+
Warnings:
16+
Warning 3996 Changing innodb_extend_and_initialize not supported on this platform. Falling back to the default.
17+
select @@global.innodb_extend_and_initialize;
18+
@@global.innodb_extend_and_initialize
19+
1
20+
# restart: --innodb-extend-and-initialize=FALSE
21+
select @@global.innodb_extend_and_initialize;
22+
@@global.innodb_extend_and_initialize
23+
1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
--innodb-page-size=16k
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
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;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
--source include/have_innodb_16k.inc
2+
--source include/not_valgrind.inc
3+
--source include/windows.inc
4+
5+
call mtr.add_suppression("\\[Warning\\] .*MY-\\d+.* Changing innodb_extend_and_initialize not supported on this platform. Falling back to the default.");
6+
7+
SELECT @@GLOBAL.INNODB_EXTEND_AND_INITIALIZE;
8+
9+
select @@global.innodb_extend_and_initialize;
10+
11+
SET @@GLOBAL.INNODB_EXTEND_AND_INITIALIZE = FALSE;
12+
select @@global.innodb_extend_and_initialize;
13+
14+
SET PERSIST INNODB_EXTEND_AND_INITIALIZE = FALSE;
15+
select @@global.innodb_extend_and_initialize;
16+
17+
let $restart_parameters = restart: --innodb-extend-and-initialize=FALSE;
18+
--source include/restart_mysqld.inc
19+
select @@global.innodb_extend_and_initialize;

0 commit comments

Comments
 (0)