Skip to content

Commit eb2c170

Browse files
author
Jan Lindström
committed
MDEV-8303; Dumping buffer pool noisy in the logs.
Added new dynamic configuration variable innodb_buf_dump_status_frequency to configure how often buffer pool dump status is printed in the logs. A number between [0, 100] that tells how oftern buffer pool dump status in percentages should be printed. E.g. 10 means that buffer pool dump status is printed when every 10% of number of buffer pool pages are dumped. Default is 0 (only start and end status is printed).
1 parent b94eaff commit eb2c170

File tree

10 files changed

+137
-2
lines changed

10 files changed

+137
-2
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
SET @start_innodb_buf_dump_status_frequency = @@global.innodb_buf_dump_status_frequency;
2+
SELECT @start_innodb_buf_dump_status_frequency;
3+
@start_innodb_buf_dump_status_frequency
4+
0
5+
SELECT COUNT(@@global.innodb_buf_dump_status_frequency);
6+
COUNT(@@global.innodb_buf_dump_status_frequency)
7+
1
8+
SET @@global.innodb_buf_dump_status_frequency = 20;
9+
SELECT @@global.innodb_buf_dump_status_frequency;
10+
@@global.innodb_buf_dump_status_frequency
11+
20
12+
SET @@global.innodb_buf_dump_status_frequency = 0;
13+
SELECT @@global.innodb_buf_dump_status_frequency;
14+
@@global.innodb_buf_dump_status_frequency
15+
0
16+
SET @@global.innodb_buf_dump_status_frequency = 100;
17+
SELECT @@global.innodb_buf_dump_status_frequency;
18+
@@global.innodb_buf_dump_status_frequency
19+
100
20+
SET @@global.innodb_buf_dump_status_frequency = -1;
21+
Warnings:
22+
Warning 1292 Truncated incorrect innodb_buf_dump_status_frequency value: '-1'
23+
SELECT @@global.innodb_buf_dump_status_frequency;
24+
@@global.innodb_buf_dump_status_frequency
25+
0
26+
SET @@global.innodb_buf_dump_status_frequency = 101;
27+
Warnings:
28+
Warning 1292 Truncated incorrect innodb_buf_dump_status_frequency value: '101'
29+
SELECT @@global.innodb_buf_dump_status_frequency;
30+
@@global.innodb_buf_dump_status_frequency
31+
100
32+
SET @@global.innodb_buf_dump_status_frequency = 10.5;
33+
ERROR 42000: Incorrect argument type to variable 'innodb_buf_dump_status_frequency'
34+
SELECT @@global.innodb_buf_dump_status_frequency;
35+
@@global.innodb_buf_dump_status_frequency
36+
100
37+
SET @@global.innodb_buf_dump_status_frequency = "abc";
38+
ERROR 42000: Incorrect argument type to variable 'innodb_buf_dump_status_frequency'
39+
SELECT @@global.innodb_buf_dump_status_frequency;
40+
@@global.innodb_buf_dump_status_frequency
41+
100
42+
SET @@global.innodb_buf_dump_status_frequency = @start_innodb_buf_dump_status_frequency;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
--source include/have_innodb.inc
2+
--source include/load_sysvars.inc
3+
4+
SET @start_innodb_buf_dump_status_frequency = @@global.innodb_buf_dump_status_frequency;
5+
SELECT @start_innodb_buf_dump_status_frequency;
6+
7+
SELECT COUNT(@@global.innodb_buf_dump_status_frequency);
8+
9+
# test valid value
10+
SET @@global.innodb_buf_dump_status_frequency = 20;
11+
SELECT @@global.innodb_buf_dump_status_frequency;
12+
13+
# test valid min
14+
SET @@global.innodb_buf_dump_status_frequency = 0;
15+
SELECT @@global.innodb_buf_dump_status_frequency;
16+
17+
# test valid max
18+
SET @@global.innodb_buf_dump_status_frequency = 100;
19+
SELECT @@global.innodb_buf_dump_status_frequency;
20+
21+
# test invalid value < min
22+
SET @@global.innodb_buf_dump_status_frequency = -1;
23+
SELECT @@global.innodb_buf_dump_status_frequency;
24+
25+
# test invalid value > max
26+
SET @@global.innodb_buf_dump_status_frequency = 101;
27+
SELECT @@global.innodb_buf_dump_status_frequency;
28+
29+
# test wrong type
30+
--Error ER_WRONG_TYPE_FOR_VAR
31+
SET @@global.innodb_buf_dump_status_frequency = 10.5;
32+
SELECT @@global.innodb_buf_dump_status_frequency;
33+
34+
--Error ER_WRONG_TYPE_FOR_VAR
35+
SET @@global.innodb_buf_dump_status_frequency = "abc";
36+
SELECT @@global.innodb_buf_dump_status_frequency;
37+
38+
SET @@global.innodb_buf_dump_status_frequency = @start_innodb_buf_dump_status_frequency;
39+

storage/innobase/buf/buf0dump.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ buf_dump(
211211
buf_dump_t* dump;
212212
ulint n_pages;
213213
ulint j;
214+
ulint limit;
215+
ulint counter;
214216

215217
buf_pool = buf_pool_from_array(i);
216218

@@ -254,6 +256,9 @@ buf_dump(
254256

255257
buf_pool_mutex_exit(buf_pool);
256258

259+
limit = (ulint)((double)n_pages * ((double)srv_buf_dump_status_frequency / (double)100));
260+
counter = 0;
261+
257262
for (j = 0; j < n_pages && !SHOULD_QUIT(); j++) {
258263
ret = fprintf(f, ULINTPF "," ULINTPF "\n",
259264
BUF_DUMP_SPACE(dump[j]),
@@ -268,7 +273,14 @@ buf_dump(
268273
return;
269274
}
270275

271-
if (j % 128 == 0) {
276+
counter++;
277+
278+
/* Print buffer pool dump status only if
279+
srv_buf_dump_status_frequency is > 0 and
280+
we have processed that amount of pages. */
281+
if (srv_buf_dump_status_frequency &&
282+
counter == limit) {
283+
counter = 0;
272284
buf_dump_status(
273285
STATUS_INFO,
274286
"Dumping buffer pool "

storage/innobase/handler/ha_innodb.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18985,6 +18985,14 @@ static MYSQL_SYSVAR_BOOL(disable_background_merge,
1898518985
NULL, NULL, FALSE);
1898618986
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
1898718987

18988+
static MYSQL_SYSVAR_ULONG(buf_dump_status_frequency, srv_buf_dump_status_frequency,
18989+
PLUGIN_VAR_RQCMDARG,
18990+
"A number between [0, 100] that tells how oftern buffer pool dump status "
18991+
"in percentages should be printed. E.g. 10 means that buffer pool dump "
18992+
"status is printed when every 10% of number of buffer pool pages are "
18993+
"dumped. Default is 0 (only start and end status is printed).",
18994+
NULL, NULL, 0, 0, 100, 0);
18995+
1898818996
#ifdef WITH_INNODB_DISALLOW_WRITES
1898918997
/*******************************************************
1899018998
* innobase_disallow_writes variable definition *
@@ -19485,6 +19493,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
1948519493
MYSQL_SYSVAR(debug_force_scrubbing),
1948619494
#endif
1948719495
MYSQL_SYSVAR(instrument_semaphores),
19496+
MYSQL_SYSVAR(buf_dump_status_frequency),
1948819497
NULL
1948919498
};
1949019499

storage/innobase/include/srv0srv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,6 +563,9 @@ extern ulong srv_fatal_semaphore_wait_threshold;
563563
/** Enable semaphore request instrumentation */
564564
extern my_bool srv_instrument_semaphores;
565565

566+
/** Buffer pool dump status frequence in percentages */
567+
extern ulong srv_buf_dump_status_frequency;
568+
566569
# ifdef UNIV_PFS_THREAD
567570
/* Keys to register InnoDB threads with performance schema */
568571
extern mysql_pfs_key_t buf_page_cleaner_thread_key;

storage/innobase/srv/srv0srv.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,9 @@ current_time % 5 != 0. */
544544
/** Simulate compression failures. */
545545
UNIV_INTERN uint srv_simulate_comp_failures = 0;
546546

547+
/** Buffer pool dump status frequence in percentages */
548+
UNIV_INTERN ulong srv_buf_dump_status_frequency = 0;
549+
547550
/** Acquire the system_mutex. */
548551
#define srv_sys_mutex_enter() do { \
549552
mutex_enter(&srv_sys->mutex); \

storage/xtradb/buf/buf0dump.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ buf_dump(
211211
buf_dump_t* dump;
212212
ulint n_pages;
213213
ulint j;
214+
ulint limit;
215+
ulint counter;
214216

215217
buf_pool = buf_pool_from_array(i);
216218

@@ -254,6 +256,9 @@ buf_dump(
254256

255257
mutex_exit(&buf_pool->LRU_list_mutex);
256258

259+
limit = (ulint)((double)n_pages * ((double)srv_buf_dump_status_frequency / (double)100));
260+
counter = 0;
261+
257262
for (j = 0; j < n_pages && !SHOULD_QUIT(); j++) {
258263
ret = fprintf(f, ULINTPF "," ULINTPF "\n",
259264
BUF_DUMP_SPACE(dump[j]),
@@ -268,7 +273,14 @@ buf_dump(
268273
return;
269274
}
270275

271-
if (j % 128 == 0) {
276+
counter++;
277+
278+
/* Print buffer pool dump status only if
279+
srv_buf_dump_status_frequency is > 0 and
280+
we have processed that amount of pages. */
281+
if (srv_buf_dump_status_frequency &&
282+
counter == limit) {
283+
counter = 0;
272284
buf_dump_status(
273285
STATUS_INFO,
274286
"Dumping buffer pool "

storage/xtradb/handler/ha_innodb.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20151,6 +20151,14 @@ static MYSQL_SYSVAR_BOOL(disable_background_merge,
2015120151
NULL, NULL, FALSE);
2015220152
#endif /* UNIV_DEBUG || UNIV_IBUF_DEBUG */
2015320153

20154+
static MYSQL_SYSVAR_ULONG(buf_dump_status_frequency, srv_buf_dump_status_frequency,
20155+
PLUGIN_VAR_RQCMDARG,
20156+
"A number between [0, 100] that tells how oftern buffer pool dump status "
20157+
"in percentages should be printed. E.g. 10 means that buffer pool dump "
20158+
"status is printed when every 10% of number of buffer pool pages are "
20159+
"dumped. Default is 0 (only start and end status is printed).",
20160+
NULL, NULL, 0, 0, 100, 0);
20161+
2015420162
#ifdef WITH_INNODB_DISALLOW_WRITES
2015520163
/*******************************************************
2015620164
* innobase_disallow_writes variable definition *
@@ -20728,6 +20736,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
2072820736
MYSQL_SYSVAR(debug_force_scrubbing),
2072920737
#endif
2073020738
MYSQL_SYSVAR(instrument_semaphores),
20739+
MYSQL_SYSVAR(buf_dump_status_frequency),
2073120740
NULL
2073220741
};
2073320742

storage/xtradb/include/srv0srv.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,9 @@ extern ulong srv_fatal_semaphore_wait_threshold;
706706
/** Enable semaphore request instrumentation */
707707
extern my_bool srv_instrument_semaphores;
708708

709+
/** Buffer pool dump status frequence in percentages */
710+
extern ulong srv_buf_dump_status_frequency;
711+
709712
# ifdef UNIV_PFS_THREAD
710713
/* Keys to register InnoDB threads with performance schema */
711714
extern mysql_pfs_key_t buf_page_cleaner_thread_key;

storage/xtradb/srv/srv0srv.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,9 @@ current_time % 5 != 0. */
688688
#endif /* MEM_PERIODIC_CHECK */
689689
# define SRV_MASTER_DICT_LRU_INTERVAL (47)
690690

691+
/** Buffer pool dump status frequence in percentages */
692+
UNIV_INTERN ulong srv_buf_dump_status_frequency = 0;
693+
691694
/** Acquire the system_mutex. */
692695
#define srv_sys_mutex_enter() do { \
693696
mutex_enter(&srv_sys->mutex); \

0 commit comments

Comments
 (0)