Commit 19e76814 authored by Sergei Golubchik's avatar Sergei Golubchik

clarify/simplify new innodb sysvars: innodb-scrub-log-interval

rename to innodb-scrub-log-speed
parent 72c8b3fc
SELECT @@GLOBAL.innodb_scrub_log_interval;
@@GLOBAL.innodb_scrub_log_interval
2000
200 Expected
SET @@GLOBAL.innodb_scrub_log_interval=100;
1 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval;
@@GLOBAL.innodb_scrub_log_interval
100
100 Expected
SET @@GLOBAL.innodb_scrub_log_interval=DEFAULT;
1 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval;
@@GLOBAL.innodb_scrub_log_interval
2000
200 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_scrub_log_interval';
@@GLOBAL.innodb_scrub_log_interval = VARIABLE_VALUE
1
1 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval;
@@GLOBAL.innodb_scrub_log_interval
2000
200 Expected
SELECT VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_scrub_log_interval';
VARIABLE_VALUE
2000
200 Expected
SELECT @@innodb_scrub_log_interval = @@GLOBAL.innodb_scrub_log_interval;
@@innodb_scrub_log_interval = @@GLOBAL.innodb_scrub_log_interval
1
1 Expected
SELECT @@innodb_scrub_log_interval;
@@innodb_scrub_log_interval
2000
200 Expected
SELECT @@local.innodb_scrub_log_interval;
ERROR HY000: Variable 'innodb_scrub_log_interval' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT @@SESSION.innodb_scrub_log_interval;
ERROR HY000: Variable 'innodb_scrub_log_interval' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT @@GLOBAL.innodb_scrub_log_interval;
@@GLOBAL.innodb_scrub_log_interval
2000
200 Expected
SELECT innodb_scrub_log_interval;
ERROR 42S22: Unknown column 'innodb_scrub_log_interval' in 'field list'
Expected error 'Unknow column in field list'
SELECT @@GLOBAL.innodb_scrub_log_speed;
@@GLOBAL.innodb_scrub_log_speed
256
200 Expected
SET @@GLOBAL.innodb_scrub_log_speed=100;
1 Expected
SELECT @@GLOBAL.innodb_scrub_log_speed;
@@GLOBAL.innodb_scrub_log_speed
100
100 Expected
SET @@GLOBAL.innodb_scrub_log_speed=DEFAULT;
1 Expected
SELECT @@GLOBAL.innodb_scrub_log_speed;
@@GLOBAL.innodb_scrub_log_speed
256
200 Expected
SELECT @@GLOBAL.innodb_scrub_log_speed = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_scrub_log_speed';
@@GLOBAL.innodb_scrub_log_speed = VARIABLE_VALUE
1
1 Expected
SELECT @@GLOBAL.innodb_scrub_log_speed;
@@GLOBAL.innodb_scrub_log_speed
256
200 Expected
SELECT VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_scrub_log_speed';
VARIABLE_VALUE
256
200 Expected
SELECT @@innodb_scrub_log_speed = @@GLOBAL.innodb_scrub_log_speed;
@@innodb_scrub_log_speed = @@GLOBAL.innodb_scrub_log_speed
1
1 Expected
SELECT @@innodb_scrub_log_speed;
@@innodb_scrub_log_speed
256
200 Expected
SELECT @@local.innodb_scrub_log_speed;
ERROR HY000: Variable 'innodb_scrub_log_speed' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT @@SESSION.innodb_scrub_log_speed;
ERROR HY000: Variable 'innodb_scrub_log_speed' is a GLOBAL variable
Expected error 'Variable is a GLOBAL variable'
SELECT @@GLOBAL.innodb_scrub_log_speed;
@@GLOBAL.innodb_scrub_log_speed
256
200 Expected
SELECT innodb_scrub_log_speed;
ERROR 42S22: Unknown column 'innodb_scrub_log_speed' in 'field list'
Expected error 'Unknow column in field list'
......@@ -1867,16 +1867,16 @@ NUMERIC_BLOCK_SIZE NULL
ENUM_VALUE_LIST NULL
READ_ONLY YES
COMMAND_LINE_ARGUMENT OPTIONAL
VARIABLE_NAME INNODB_SCRUB_LOG_INTERVAL
VARIABLE_NAME INNODB_SCRUB_LOG_SPEED
SESSION_VALUE NULL
GLOBAL_VALUE 2000
GLOBAL_VALUE 256
GLOBAL_VALUE_ORIGIN COMPILE-TIME
DEFAULT_VALUE 2000
DEFAULT_VALUE 256
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT Innodb redo log scrubbing interval in ms
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 18446744073709551615
VARIABLE_COMMENT Background redo log scrubbing speed in bytes/sec
NUMERIC_MIN_VALUE 1
NUMERIC_MAX_VALUE 50000
NUMERIC_BLOCK_SIZE 0
ENUM_VALUE_LIST NULL
READ_ONLY NO
......
--source include/have_innodb.inc
# Display default value
SELECT @@GLOBAL.innodb_scrub_log_interval;
SELECT @@GLOBAL.innodb_scrub_log_speed;
--echo 200 Expected
# Check if value can be set
SET @@GLOBAL.innodb_scrub_log_interval=100;
SET @@GLOBAL.innodb_scrub_log_speed=100;
--echo 1 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval;
SELECT @@GLOBAL.innodb_scrub_log_speed;
--echo 100 Expected
SET @@GLOBAL.innodb_scrub_log_interval=DEFAULT;
SET @@GLOBAL.innodb_scrub_log_speed=DEFAULT;
--echo 1 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval;
SELECT @@GLOBAL.innodb_scrub_log_speed;
--echo 200 Expected
# Check if the value in GLOBAL TABLE matches value in variable
SELECT @@GLOBAL.innodb_scrub_log_interval = VARIABLE_VALUE
SELECT @@GLOBAL.innodb_scrub_log_speed = VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_scrub_log_interval';
WHERE VARIABLE_NAME='innodb_scrub_log_speed';
--echo 1 Expected
SELECT @@GLOBAL.innodb_scrub_log_interval;
SELECT @@GLOBAL.innodb_scrub_log_speed;
--echo 200 Expected
SELECT VARIABLE_VALUE
FROM INFORMATION_SCHEMA.GLOBAL_VARIABLES
WHERE VARIABLE_NAME='innodb_scrub_log_interval';
WHERE VARIABLE_NAME='innodb_scrub_log_speed';
--echo 200 Expected
# Check if accessing variable with and without GLOBAL point to same variable
SELECT @@innodb_scrub_log_interval = @@GLOBAL.innodb_scrub_log_interval;
SELECT @@innodb_scrub_log_speed = @@GLOBAL.innodb_scrub_log_speed;
--echo 1 Expected
# Check if innodb_scrub_log_interval can be accessed with and without @@ sign
SELECT @@innodb_scrub_log_interval;
# Check if innodb_scrub_log_speed can be accessed with and without @@ sign
SELECT @@innodb_scrub_log_speed;
--echo 200 Expected
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@local.innodb_scrub_log_interval;
SELECT @@local.innodb_scrub_log_speed;
--echo Expected error 'Variable is a GLOBAL variable'
--Error ER_INCORRECT_GLOBAL_LOCAL_VAR
SELECT @@SESSION.innodb_scrub_log_interval;
SELECT @@SESSION.innodb_scrub_log_speed;
--echo Expected error 'Variable is a GLOBAL variable'
SELECT @@GLOBAL.innodb_scrub_log_interval;
SELECT @@GLOBAL.innodb_scrub_log_speed;
--echo 200 Expected
--Error ER_BAD_FIELD_ERROR
SELECT innodb_scrub_log_interval;
SELECT innodb_scrub_log_speed;
--echo Expected error 'Unknow column in field list'
......@@ -19163,21 +19163,13 @@ static MYSQL_SYSVAR_BOOL(scrub_log, srv_scrub_log,
"Enable redo log scrubbing",
0, 0, 0);
/*
If innodb_scrub_log is on, logs will be scrubbed in less than
(((innodb_log_file_size * innodb_log_files_in_group) / 512 ) /
((1000 * 86400) / innodb_scrub_log_interval))
days.
In above formula, the first line calculates the number of log blocks to scrub,
and the second line calculates the number of log blocks scrubbed in one day.
*/
static MYSQL_SYSVAR_ULONGLONG(scrub_log_interval, innodb_scrub_log_interval,
static MYSQL_SYSVAR_ULONGLONG(scrub_log_speed, innodb_scrub_log_speed,
PLUGIN_VAR_OPCMDARG,
"Innodb redo log scrubbing interval in ms",
"Background redo log scrubbing speed in bytes/sec",
NULL, NULL,
2000, /* default */
10, /* min */
ULONGLONG_MAX, 0);/* max */
256, /* 256 bytes/sec, corresponds to 2000 ms scrub_log_interval */
1, /* min */
50000, 0); /* 50Kbyte/sec, corresponds to 10 ms scrub_log_interval */
static MYSQL_SYSVAR_BOOL(encrypt_log, srv_encrypt_log,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
......@@ -19423,7 +19415,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(encryption_rotate_key_age),
MYSQL_SYSVAR(encryption_rotation_iops),
MYSQL_SYSVAR(scrub_log),
MYSQL_SYSVAR(scrub_log_interval),
MYSQL_SYSVAR(scrub_log_speed),
MYSQL_SYSVAR(encrypt_log),
MYSQL_SYSVAR(default_page_encryption_key),
......
......@@ -1022,8 +1022,8 @@ struct log_t{
#endif /* UNIV_LOG_ARCHIVE */
extern os_event_t log_scrub_event;
/* log scrubbing interval in ms */
extern ulonglong innodb_scrub_log_interval;
/* log scrubbing speed, in bytes/sec */
extern ulonglong innodb_scrub_log_speed;
/*****************************************************************//**
This is the main thread for log scrub. It waits for an event and
......
......@@ -3857,8 +3857,8 @@ log_scrub()
next_lbn_to_pad = log_block_convert_lsn_to_no(log_sys->lsn);
}
/* log scrubbing interval in ms. */
UNIV_INTERN ulonglong innodb_scrub_log_interval;
/* log scrubbing speed, in bytes/sec */
UNIV_INTERN ulonglong innodb_scrub_log_speed;
/*****************************************************************//**
This is the main thread for log scrub. It waits for an event and
......@@ -3878,7 +3878,10 @@ DECLARE_THREAD(log_scrub_thread)(
while(srv_shutdown_state == SRV_SHUTDOWN_NONE)
{
os_event_wait_time(log_scrub_event, innodb_scrub_log_interval * 1000);
/* log scrubbing interval in µs. */
ulonglong interval = 1000*1000*512/innodb_scrub_log_speed;
os_event_wait_time(log_scrub_event, interval);
log_scrub();
......
......@@ -20346,21 +20346,13 @@ static MYSQL_SYSVAR_BOOL(scrub_log, srv_scrub_log,
"Enable redo log scrubbing",
0, 0, 0);
/*
If innodb_scrub_log is on, logs will be scrubbed in less than
(((innodb_log_file_size * innodb_log_files_in_group) / 512 ) /
((1000 * 86400) / innodb_scrub_log_interval))
days.
In above formula, the first line calculates the number of log blocks to scrub,
and the second line calculates the number of log blocks scrubbed in one day.
*/
static MYSQL_SYSVAR_ULONGLONG(scrub_log_interval, innodb_scrub_log_interval,
static MYSQL_SYSVAR_ULONGLONG(scrub_log_speed, innodb_scrub_log_speed,
PLUGIN_VAR_OPCMDARG,
"Innodb redo log scrubbing interval in ms",
"Background redo log scrubbing speed in bytes/sec",
NULL, NULL,
2000, /* default */
10, /* min */
ULONGLONG_MAX, 0);/* max */
256, /* 256 bytes/sec, corresponds to 2000 ms scrub_log_interval */
1, /* min */
50000, 0); /* 50Kbyte/sec, corresponds to 10 ms scrub_log_interval */
static MYSQL_SYSVAR_BOOL(encrypt_log, srv_encrypt_log,
PLUGIN_VAR_OPCMDARG | PLUGIN_VAR_READONLY,
......@@ -20644,7 +20636,7 @@ static struct st_mysql_sys_var* innobase_system_variables[]= {
MYSQL_SYSVAR(encryption_rotate_key_age),
MYSQL_SYSVAR(encryption_rotation_iops),
MYSQL_SYSVAR(scrub_log),
MYSQL_SYSVAR(scrub_log_interval),
MYSQL_SYSVAR(scrub_log_speed),
MYSQL_SYSVAR(encrypt_log),
MYSQL_SYSVAR(default_page_encryption_key),
/* Scrubing feature */
......
......@@ -1101,8 +1101,8 @@ struct log_t{
#endif /* UNIV_LOG_ARCHIVE */
extern os_event_t log_scrub_event;
/* log scrubbing interval in ms */
extern ulonglong innodb_scrub_log_interval;
/* log scrubbing speed, in bytes/sec */
extern ulonglong innodb_scrub_log_speed;
/*****************************************************************//**
This is the main thread for log scrub. It waits for an event and
......
......@@ -4187,8 +4187,8 @@ log_scrub()
next_lbn_to_pad = log_block_convert_lsn_to_no(log_sys->lsn);
}
/* log scrubbing interval in ms. */
UNIV_INTERN ulonglong innodb_scrub_log_interval;
/* log scrubbing speed, in bytes/sec */
UNIV_INTERN ulonglong innodb_scrub_log_speed;
/*****************************************************************//**
This is the main thread for log scrub. It waits for an event and
......@@ -4208,7 +4208,10 @@ DECLARE_THREAD(log_scrub_thread)(
while(srv_shutdown_state == SRV_SHUTDOWN_NONE)
{
os_event_wait_time(log_scrub_event, innodb_scrub_log_interval * 1000);
/* log scrubbing interval in µs. */
ulonglong interval = 1000*1000*512/innodb_scrub_log_speed;
os_event_wait_time(log_scrub_event, interval);
log_scrub();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment