Skip to content

Commit a993310

Browse files
committed
MDEV-24537 innodb_max_dirty_pages_pct_lwm=0 lost its special meaning
In commit 3a9a3be (MDEV-23855) some previous logic was replaced with the condition dirty_pct < srv_max_dirty_pages_pct_lwm, which caused the default value of the parameter innodb_max_dirty_pages_pct_lwm=0 to lose its special meaning: 'refer to innodb_max_dirty_pages_pct instead'. This implicit special meaning was visible in the function af_get_pct_for_dirty(), which was removed in commit f0c295e (MDEV-24369). page_cleaner_flush_pages_recommendation(): Restore the special meaning that was removed in MDEV-24369. buf_flush_page_cleaner(): If srv_max_dirty_pages_pct_lwm==0.0, refer to srv_max_buf_pool_modified_pct. This fixes the observed performance regression due to excessive page flushing. buf_pool_t::page_cleaner_wakeup(): Revise the wakeup condition. innodb_init(): Do initialize srv_max_io_capacity in Mariabackup. It was previously constantly 0, which caused mariadb-backup --prepare to hang in buf_flush_sync(), making no progress.
1 parent 02e7bff commit a993310

File tree

5 files changed

+30
-15
lines changed

5 files changed

+30
-15
lines changed

extra/mariabackup/xtrabackup.cc

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ MariaBackup: hot backup tool for InnoDB
44
Originally Created 3/3/2009 Yasufumi Kinoshita
55
Written by Alexey Kopytov, Aleksandr Kuzminsky, Stewart Smith, Vadim Tkachenko,
66
Yasufumi Kinoshita, Ignacio Nin and Baron Schwartz.
7-
(c) 2017, 2020, MariaDB Corporation.
7+
(c) 2017, 2021, MariaDB Corporation.
88
Portions written by Marko Mäkelä.
99
1010
This program is free software; you can redistribute it and/or modify
@@ -2183,6 +2183,14 @@ static bool innodb_init_param()
21832183
static bool innodb_init()
21842184
{
21852185
bool create_new_db = false;
2186+
2187+
if (srv_io_capacity >= SRV_MAX_IO_CAPACITY_LIMIT / 2) {
2188+
/* Avoid overflow. */
2189+
srv_max_io_capacity = SRV_MAX_IO_CAPACITY_LIMIT;
2190+
} else {
2191+
srv_max_io_capacity = std::max(2 * srv_io_capacity, 2000UL);
2192+
}
2193+
21862194
/* Check if the data files exist or not. */
21872195
dberr_t err = srv_sys_space.check_file_spec(&create_new_db, 5U << 20);
21882196

mysql-test/suite/sys_vars/r/sysvars_innodb.result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ SESSION_VALUE NULL
13221322
DEFAULT_VALUE 0.000000
13231323
VARIABLE_SCOPE GLOBAL
13241324
VARIABLE_TYPE DOUBLE
1325-
VARIABLE_COMMENT Percentage of dirty pages at which flushing kicks in.
1325+
VARIABLE_COMMENT Percentage of dirty pages at which flushing kicks in. The value 0 (default) means 'refer to innodb_max_dirty_pages_pct'.
13261326
NUMERIC_MIN_VALUE 0
13271327
NUMERIC_MAX_VALUE 99.999
13281328
NUMERIC_BLOCK_SIZE NULL

storage/innobase/buf/buf0flu.cc

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
33
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2013, 2020, MariaDB Corporation.
4+
Copyright (c) 2013, 2021, MariaDB Corporation.
55
Copyright (c) 2013, 2014, Fusion-io
66
77
This program is free software; you can redistribute it and/or modify it under
@@ -129,11 +129,13 @@ static void buf_flush_validate_skip()
129129
/** Wake up the page cleaner if needed */
130130
inline void buf_pool_t::page_cleaner_wakeup()
131131
{
132-
if (page_cleaner_idle() &&
133-
(srv_max_dirty_pages_pct_lwm == 0.0 ||
134-
srv_max_dirty_pages_pct_lwm <=
135-
double(UT_LIST_GET_LEN(buf_pool.flush_list)) * 100.0 /
136-
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free))))
132+
if (!page_cleaner_idle())
133+
return;
134+
double dirty_pct= double(UT_LIST_GET_LEN(buf_pool.flush_list)) * 100.0 /
135+
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free));
136+
double pct_lwm= srv_max_dirty_pages_pct_lwm;
137+
if ((pct_lwm != 0.0 && pct_lwm <= dirty_pct) ||
138+
srv_max_buf_pool_modified_pct <= dirty_pct)
137139
{
138140
page_cleaner_is_idle= false;
139141
mysql_cond_signal(&do_flush_list);
@@ -1989,7 +1991,9 @@ static ulint page_cleaner_flush_pages_recommendation(ulint last_pages_in,
19891991
sum_pages = 0;
19901992
}
19911993

1992-
const ulint pct_for_dirty = static_cast<ulint>
1994+
const ulint pct_for_dirty = srv_max_dirty_pages_pct_lwm == 0
1995+
? (dirty_pct >= max_pct ? 100 : 0)
1996+
: static_cast<ulint>
19931997
(max_pct > 0.0 ? dirty_pct / max_pct : dirty_pct);
19941998
ulint pct_total = std::max(pct_for_dirty, pct_for_lsn);
19951999

@@ -2129,7 +2133,11 @@ static os_thread_ret_t DECLARE_THREAD(buf_flush_page_cleaner)(void*)
21292133
const double dirty_pct= double(dirty_blocks) * 100.0 /
21302134
double(UT_LIST_GET_LEN(buf_pool.LRU) + UT_LIST_GET_LEN(buf_pool.free));
21312135

2132-
if (dirty_pct < srv_max_dirty_pages_pct_lwm && !lsn_limit)
2136+
if (lsn_limit);
2137+
else if (dirty_pct < srv_max_buf_pool_modified_pct)
2138+
goto unemployed;
2139+
else if (srv_max_dirty_pages_pct_lwm == 0.0 ||
2140+
dirty_pct < srv_max_dirty_pages_pct_lwm)
21332141
goto unemployed;
21342142

21352143
const lsn_t oldest_lsn= buf_pool.get_oldest_modified()

storage/innobase/handler/ha_innodb.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19032,7 +19032,8 @@ static MYSQL_SYSVAR_DOUBLE(max_dirty_pages_pct, srv_max_buf_pool_modified_pct,
1903219032
static MYSQL_SYSVAR_DOUBLE(max_dirty_pages_pct_lwm,
1903319033
srv_max_dirty_pages_pct_lwm,
1903419034
PLUGIN_VAR_RQCMDARG,
19035-
"Percentage of dirty pages at which flushing kicks in.",
19035+
"Percentage of dirty pages at which flushing kicks in. "
19036+
"The value 0 (default) means 'refer to innodb_max_dirty_pages_pct'.",
1903619037
NULL, innodb_max_dirty_pages_pct_lwm_update, 0, 0, 99.999, 0);
1903719038

1903819039
static MYSQL_SYSVAR_DOUBLE(adaptive_flushing_lwm,

storage/innobase/include/srv0srv.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Copyright (c) 1995, 2017, Oracle and/or its affiliates. All rights reserved.
44
Copyright (c) 2008, 2009, Google Inc.
55
Copyright (c) 2009, Percona Inc.
6-
Copyright (c) 2013, 2020, MariaDB Corporation.
6+
Copyright (c) 2013, 2021, MariaDB Corporation.
77
88
Portions of this file contain modifications contributed and copyrighted by
99
Google, Inc. Those modifications are gratefully acknowledged and are described
@@ -373,7 +373,7 @@ extern ulong srv_innodb_stats_method;
373373

374374
extern ulint srv_max_n_open_files;
375375

376-
extern double srv_max_dirty_pages_pct;
376+
extern double srv_max_buf_pool_modified_pct;
377377
extern double srv_max_dirty_pages_pct_lwm;
378378

379379
extern double srv_adaptive_flushing_lwm;
@@ -400,10 +400,8 @@ extern my_bool srv_stats_sample_traditional;
400400
extern my_bool srv_use_doublewrite_buf;
401401
extern ulong srv_checksum_algorithm;
402402

403-
extern double srv_max_buf_pool_modified_pct;
404403
extern my_bool srv_force_primary_key;
405404

406-
extern double srv_max_buf_pool_modified_pct;
407405
extern ulong srv_max_purge_lag;
408406
extern ulong srv_max_purge_lag_delay;
409407

0 commit comments

Comments
 (0)