forked from twitter-forks/mysql
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MYSQL-45: InnoDB should allow flushing to be gated by age of pages
Currently using innodb_max_dirty_pages_pct especially with a large innodb_io_capacity does not enforce any lower limit on the number of dirty pages, and this can increase the number of writes dramatically. While normally this would be OK (flush if you can) this is not desirable behavior on SSDs where write lifetime is limited. In order to reduce and control the frequency of write requests to SSD, this change introduces a new variable named innodb_flush_dirty_pages_age which can be used to set the minimum age of dirty pages to be flushed from the buffer pool if the number of dirty pages is below the maximum percentage. This impacts the frequency with which frequently modified pages are flushed, which can help reduce IO load in systems with frequently modified pages (hot spots).
- Loading branch information
Davi Arnaut
committed
Feb 11, 2012
1 parent
9256eea
commit 436e5ff
Showing
5 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
56 changes: 56 additions & 0 deletions
56
mysql-test/suite/sys_vars/r/innodb_flush_dirty_pages_age_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
SET @start_global_value = @@global.innodb_flush_dirty_pages_age; | ||
SELECT @start_global_value; | ||
@start_global_value | ||
0 | ||
Valid values are zero or above | ||
select @@global.innodb_flush_dirty_pages_age >=0; | ||
@@global.innodb_flush_dirty_pages_age >=0 | ||
1 | ||
select @@global.innodb_flush_dirty_pages_age; | ||
@@global.innodb_flush_dirty_pages_age | ||
0 | ||
select @@session.innodb_flush_dirty_pages_age; | ||
ERROR HY000: Variable 'innodb_flush_dirty_pages_age' is a GLOBAL variable | ||
show global variables like 'innodb_flush_dirty_pages_age'; | ||
Variable_name Value | ||
innodb_flush_dirty_pages_age 0 | ||
show session variables like 'innodb_flush_dirty_pages_age'; | ||
Variable_name Value | ||
innodb_flush_dirty_pages_age 0 | ||
select * from information_schema.global_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
INNODB_FLUSH_DIRTY_PAGES_AGE 0 | ||
select * from information_schema.session_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
INNODB_FLUSH_DIRTY_PAGES_AGE 0 | ||
set global innodb_flush_dirty_pages_age=10; | ||
select @@global.innodb_flush_dirty_pages_age; | ||
@@global.innodb_flush_dirty_pages_age | ||
10 | ||
select * from information_schema.global_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
INNODB_FLUSH_DIRTY_PAGES_AGE 10 | ||
select * from information_schema.session_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
INNODB_FLUSH_DIRTY_PAGES_AGE 10 | ||
set session innodb_flush_dirty_pages_age=1; | ||
ERROR HY000: Variable 'innodb_flush_dirty_pages_age' is a GLOBAL variable and should be set with SET GLOBAL | ||
set global innodb_flush_dirty_pages_age=1.1; | ||
ERROR 42000: Incorrect argument type to variable 'innodb_flush_dirty_pages_age' | ||
set global innodb_flush_dirty_pages_age=1e1; | ||
ERROR 42000: Incorrect argument type to variable 'innodb_flush_dirty_pages_age' | ||
set global innodb_flush_dirty_pages_age="foo"; | ||
ERROR 42000: Incorrect argument type to variable 'innodb_flush_dirty_pages_age' | ||
set global innodb_flush_dirty_pages_age=-7; | ||
Warnings: | ||
Warning 1292 Truncated incorrect innodb_flush_dirty_pages_age value: '-7' | ||
select @@global.innodb_flush_dirty_pages_age; | ||
@@global.innodb_flush_dirty_pages_age | ||
0 | ||
select * from information_schema.global_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
VARIABLE_NAME VARIABLE_VALUE | ||
INNODB_FLUSH_DIRTY_PAGES_AGE 0 | ||
SET @@global.innodb_flush_dirty_pages_age = @start_global_value; | ||
SELECT @@global.innodb_flush_dirty_pages_age; | ||
@@global.innodb_flush_dirty_pages_age | ||
0 |
52 changes: 52 additions & 0 deletions
52
mysql-test/suite/sys_vars/t/innodb_flush_dirty_pages_age_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
|
||
# | ||
# 2010-01-25 - Added | ||
# | ||
|
||
--source include/have_innodb.inc | ||
|
||
SET @start_global_value = @@global.innodb_flush_dirty_pages_age; | ||
SELECT @start_global_value; | ||
|
||
# | ||
# exists as global only | ||
# | ||
--echo Valid values are zero or above | ||
select @@global.innodb_flush_dirty_pages_age >=0; | ||
select @@global.innodb_flush_dirty_pages_age; | ||
--error ER_INCORRECT_GLOBAL_LOCAL_VAR | ||
select @@session.innodb_flush_dirty_pages_age; | ||
show global variables like 'innodb_flush_dirty_pages_age'; | ||
show session variables like 'innodb_flush_dirty_pages_age'; | ||
select * from information_schema.global_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
select * from information_schema.session_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
|
||
# | ||
# show that it's writable | ||
# | ||
set global innodb_flush_dirty_pages_age=10; | ||
select @@global.innodb_flush_dirty_pages_age; | ||
select * from information_schema.global_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
select * from information_schema.session_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
--error ER_GLOBAL_VARIABLE | ||
set session innodb_flush_dirty_pages_age=1; | ||
|
||
# | ||
# incorrect types | ||
# | ||
--error ER_WRONG_TYPE_FOR_VAR | ||
set global innodb_flush_dirty_pages_age=1.1; | ||
--error ER_WRONG_TYPE_FOR_VAR | ||
set global innodb_flush_dirty_pages_age=1e1; | ||
--error ER_WRONG_TYPE_FOR_VAR | ||
set global innodb_flush_dirty_pages_age="foo"; | ||
|
||
set global innodb_flush_dirty_pages_age=-7; | ||
select @@global.innodb_flush_dirty_pages_age; | ||
select * from information_schema.global_variables where variable_name='innodb_flush_dirty_pages_age'; | ||
|
||
# | ||
# cleanup | ||
# | ||
SET @@global.innodb_flush_dirty_pages_age = @start_global_value; | ||
SELECT @@global.innodb_flush_dirty_pages_age; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters