MDEV-6058 MySQL Bug #11766693: LOG-SLOW-ADMIN-STATEMENTS AND
LOG-SLOW-SLAVE-STATEMENTS NOT DISPLAYED. These parameters were moved from the command line options to the system variables section. Treatment of the opt_log_slow_slave_statements changed to let the dynamic change of the variable.
This commit is contained in:
parent
fd6c588659
commit
0a4a78ae8c
@ -9,8 +9,10 @@ select @@log_slow_verbosity;
|
||||
|
||||
show variables like "log_slow%";
|
||||
Variable_name Value
|
||||
log_slow_admin_statements OFF
|
||||
log_slow_filter admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
|
||||
log_slow_rate_limit 1
|
||||
log_slow_slave_statements OFF
|
||||
log_slow_verbosity
|
||||
set @org_slow_query_log= @@global.slow_query_log;
|
||||
set @@log_slow_filter= "filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk,admin";
|
||||
|
@ -76,6 +76,21 @@ ALTER TABLE t1 ADD INDEX id1(a);
|
||||
INSERT INTO t1 values(1, sleep(3));
|
||||
### Assertion is good. Both Master and Slave exhibit the
|
||||
### same number of queries in slow log: 1
|
||||
********************************************************************
|
||||
**** TRUNCATE the slow log then check whether runtime changes of
|
||||
**** log_slow_slave_statements work without slave restart.
|
||||
********************************************************************
|
||||
SET @old_log_slow_slave_statements= @@global.log_slow_slave_statements;
|
||||
SET @@global.log_slow_slave_statements = off;
|
||||
TRUNCATE mysql.slow_log;
|
||||
INSERT INTO t1 values(1, sleep(3));;
|
||||
SELECT sql_text FROM mysql.slow_log WHERE sql_text like 'INSERT INTO t1 values(1, sleep(3))';
|
||||
sql_text
|
||||
SET @@global.log_slow_slave_statements = on;
|
||||
INSERT INTO t1 values(1, sleep(3));;
|
||||
SELECT sql_text FROM mysql.slow_log WHERE sql_text like 'INSERT INTO t1 values(1, sleep(3))';
|
||||
sql_text
|
||||
INSERT INTO t1 values(1, sleep(3))
|
||||
SET @@global.log_output= @old_log_output;
|
||||
SET @@global.long_query_time= @old_long_query_time;
|
||||
DROP TABLE t1;
|
||||
|
@ -299,6 +299,39 @@ if ($master_slow_query == $slave_slow_query)
|
||||
-- echo ### same number of queries in slow log: $master_slow_query
|
||||
}
|
||||
|
||||
-- echo ********************************************************************
|
||||
-- echo **** TRUNCATE the slow log then check whether runtime changes of
|
||||
-- echo **** log_slow_slave_statements work without slave restart.
|
||||
-- echo ********************************************************************
|
||||
|
||||
SET @old_log_slow_slave_statements= @@global.log_slow_slave_statements;
|
||||
SET @@global.log_slow_slave_statements = off;
|
||||
TRUNCATE mysql.slow_log;
|
||||
|
||||
-- connection master
|
||||
|
||||
--disable_warnings
|
||||
-- eval $slow_query;
|
||||
--enable_warnings
|
||||
sync_slave_with_master;
|
||||
|
||||
-- connection slave
|
||||
|
||||
eval SELECT sql_text FROM mysql.slow_log WHERE sql_text like '$slow_query';
|
||||
|
||||
SET @@global.log_slow_slave_statements = on;
|
||||
|
||||
-- connection master
|
||||
|
||||
--disable_warnings
|
||||
-- eval $slow_query;
|
||||
--enable_warnings
|
||||
sync_slave_with_master;
|
||||
|
||||
-- connection slave
|
||||
|
||||
eval SELECT sql_text FROM mysql.slow_log WHERE sql_text like '$slow_query';
|
||||
|
||||
-- connection master
|
||||
SET @@global.log_output= @old_log_output;
|
||||
SET @@global.long_query_time= @old_long_query_time;
|
||||
|
@ -0,0 +1,46 @@
|
||||
SET @old_log_output= @@global.log_output;
|
||||
SET @old_slow_query_log= @@global.slow_query_log;
|
||||
SET @old_long_query_time= @@session.long_query_time;
|
||||
SET @old_log_slow_admin_statements= @@global.log_slow_admin_statements;
|
||||
USE test;
|
||||
CREATE TABLE log_slow_admin_statements (
|
||||
i INT PRIMARY KEY AUTO_INCREMENT,
|
||||
j VARCHAR(255)
|
||||
) ENGINE=InnoDB;
|
||||
SET GLOBAL log_output = 'file,table';
|
||||
SET GLOBAL slow_query_log = on;
|
||||
SET SESSION long_query_time = 0;
|
||||
SET GLOBAL log_slow_admin_statements = on;
|
||||
ALTER TABLE log_slow_admin_statements ADD COLUMN k INT DEFAULT 17;
|
||||
CREATE PROCEDURE add_rows()
|
||||
BEGIN
|
||||
DECLARE count INT;
|
||||
SET count = 1;
|
||||
INSERT INTO log_slow_admin_statements(j) values (REPEAT('A', 255));
|
||||
WHILE count <= 15 DO
|
||||
INSERT INTO log_slow_admin_statements(j) SELECT j FROM log_slow_admin_statements;
|
||||
SET count = count + 1;
|
||||
END WHILE;
|
||||
END
|
||||
$
|
||||
CALL add_rows();
|
||||
OPTIMIZE TABLE log_slow_admin_statements;
|
||||
Table Op Msg_type Msg_text
|
||||
test.log_slow_admin_statements optimize note Table does not support optimize, doing recreate + analyze instead
|
||||
test.log_slow_admin_statements optimize status OK
|
||||
CHECK TABLE log_slow_admin_statements EXTENDED;
|
||||
Table Op Msg_type Msg_text
|
||||
test.log_slow_admin_statements check status OK
|
||||
DROP TABLE log_slow_admin_statements;
|
||||
SELECT sql_text FROM mysql.slow_log WHERE sql_text LIKE '%TABLE log_slow_admin_statements%';
|
||||
sql_text
|
||||
ALTER TABLE log_slow_admin_statements ADD COLUMN k INT DEFAULT 17
|
||||
OPTIMIZE TABLE log_slow_admin_statements
|
||||
CHECK TABLE log_slow_admin_statements EXTENDED
|
||||
DROP TABLE log_slow_admin_statements
|
||||
SET @@global.log_output= @old_log_output;
|
||||
SET @@global.slow_query_log= @old_slow_query_log;
|
||||
SET @@session.long_query_time= @old_long_query_time;
|
||||
SET @@global.log_slow_admin_statements= @old_log_slow_admin_statements;
|
||||
DROP PROCEDURE add_rows;
|
||||
TRUNCATE TABLE mysql.slow_log;
|
@ -1829,6 +1829,20 @@ NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST OFF,ON
|
||||
READ_ONLY YES
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME LOG_SLOW_ADMIN_STATEMENTS
|
||||
SESSION_VALUE NULL
|
||||
GLOBAL_VALUE OFF
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE OFF
|
||||
VARIABLE_SCOPE GLOBAL
|
||||
VARIABLE_TYPE BOOLEAN
|
||||
VARIABLE_COMMENT Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to the slow log if it is open.
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST OFF,ON
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME LOG_SLOW_FILTER
|
||||
SESSION_VALUE admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
|
||||
GLOBAL_VALUE admin,filesort,filesort_on_disk,full_join,full_scan,query_cache,query_cache_miss,tmp_table,tmp_table_on_disk
|
||||
@ -1857,6 +1871,20 @@ NUMERIC_BLOCK_SIZE 1
|
||||
ENUM_VALUE_LIST NULL
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT REQUIRED
|
||||
VARIABLE_NAME LOG_SLOW_SLAVE_STATEMENTS
|
||||
SESSION_VALUE NULL
|
||||
GLOBAL_VALUE OFF
|
||||
GLOBAL_VALUE_ORIGIN COMPILE-TIME
|
||||
DEFAULT_VALUE OFF
|
||||
VARIABLE_SCOPE GLOBAL
|
||||
VARIABLE_TYPE BOOLEAN
|
||||
VARIABLE_COMMENT Log slow statements executed by slave thread to the slow log if it is open.
|
||||
NUMERIC_MIN_VALUE NULL
|
||||
NUMERIC_MAX_VALUE NULL
|
||||
NUMERIC_BLOCK_SIZE NULL
|
||||
ENUM_VALUE_LIST OFF,ON
|
||||
READ_ONLY NO
|
||||
COMMAND_LINE_ARGUMENT OPTIONAL
|
||||
VARIABLE_NAME LOG_SLOW_VERBOSITY
|
||||
SESSION_VALUE
|
||||
GLOBAL_VALUE
|
||||
|
@ -0,0 +1,61 @@
|
||||
--source include/no_valgrind_without_big.inc
|
||||
-- source include/have_innodb.inc
|
||||
|
||||
SET @old_log_output= @@global.log_output;
|
||||
SET @old_slow_query_log= @@global.slow_query_log;
|
||||
SET @old_long_query_time= @@session.long_query_time;
|
||||
SET @old_log_slow_admin_statements= @@global.log_slow_admin_statements;
|
||||
|
||||
USE test;
|
||||
CREATE TABLE log_slow_admin_statements (
|
||||
i INT PRIMARY KEY AUTO_INCREMENT,
|
||||
j VARCHAR(255)
|
||||
) ENGINE=InnoDB;
|
||||
|
||||
# enable slow logging to table
|
||||
SET GLOBAL log_output = 'file,table';
|
||||
SET GLOBAL slow_query_log = on;
|
||||
SET SESSION long_query_time = 0;
|
||||
SET GLOBAL log_slow_admin_statements = on;
|
||||
|
||||
# test ALTER, OPTIMIZE and CHECK against the table shown up
|
||||
ALTER TABLE log_slow_admin_statements ADD COLUMN k INT DEFAULT 17;
|
||||
|
||||
# add rows so OPTIMIZE and CHECK runs
|
||||
DELIMITER $;
|
||||
|
||||
CREATE PROCEDURE add_rows()
|
||||
BEGIN
|
||||
DECLARE count INT;
|
||||
SET count = 1;
|
||||
INSERT INTO log_slow_admin_statements(j) values (REPEAT('A', 255));
|
||||
WHILE count <= 15 DO
|
||||
INSERT INTO log_slow_admin_statements(j) SELECT j FROM log_slow_admin_statements;
|
||||
SET count = count + 1;
|
||||
END WHILE;
|
||||
END
|
||||
$
|
||||
|
||||
DELIMITER ;$
|
||||
|
||||
CALL add_rows();
|
||||
|
||||
# OPTIMIZE TABLE
|
||||
OPTIMIZE TABLE log_slow_admin_statements;
|
||||
|
||||
# CHECK TABLE
|
||||
CHECK TABLE log_slow_admin_statements EXTENDED;
|
||||
|
||||
# DROP TABLE
|
||||
DROP TABLE log_slow_admin_statements;
|
||||
|
||||
# ALTER, OPTIMIZE, CHECK and DROP operations should be logged in slow query log.
|
||||
SELECT sql_text FROM mysql.slow_log WHERE sql_text LIKE '%TABLE log_slow_admin_statements%';
|
||||
|
||||
SET @@global.log_output= @old_log_output;
|
||||
SET @@global.slow_query_log= @old_slow_query_log;
|
||||
SET @@session.long_query_time= @old_long_query_time;
|
||||
SET @@global.log_slow_admin_statements= @old_log_slow_admin_statements;
|
||||
|
||||
DROP PROCEDURE add_rows;
|
||||
TRUNCATE TABLE mysql.slow_log;
|
@ -4428,6 +4428,15 @@ int Query_log_event::do_apply_event(rpl_group_info *rgi,
|
||||
if (thd->m_digest != NULL)
|
||||
thd->m_digest->reset(thd->m_token_array, max_digest_length);
|
||||
|
||||
if (thd->slave_thread)
|
||||
{
|
||||
/*
|
||||
The opt_log_slow_slave_statements variable can be changed
|
||||
dynamically, so we have to set the sql_log_slow respectively.
|
||||
*/
|
||||
thd->variables.sql_log_slow= opt_log_slow_slave_statements;
|
||||
}
|
||||
|
||||
thd->enable_slow_log= thd->variables.sql_log_slow;
|
||||
mysql_parse(thd, thd->query(), thd->query_length(), &parser_state);
|
||||
/* Finalize server status flags after executing a statement. */
|
||||
|
@ -7372,14 +7372,6 @@ struct my_option my_long_options[]=
|
||||
"Don't log extra information to update and slow-query logs.",
|
||||
&opt_short_log_format, &opt_short_log_format,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"log-slow-admin-statements", 0,
|
||||
"Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to "
|
||||
"the slow log if it is open.", &opt_log_slow_admin_statements,
|
||||
&opt_log_slow_admin_statements, 0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"log-slow-slave-statements", 0,
|
||||
"Log slow statements executed by slave thread to the slow log if it is open.",
|
||||
&opt_log_slow_slave_statements, &opt_log_slow_slave_statements,
|
||||
0, GET_BOOL, NO_ARG, 0, 0, 0, 0, 0, 0},
|
||||
{"log-tc", 0,
|
||||
"Path to transaction coordinator log (used for transactions that affect "
|
||||
"more than one storage engine, when binary log is disabled).",
|
||||
|
@ -1183,6 +1183,19 @@ static Sys_var_mybool Sys_log_queries_not_using_indexes(
|
||||
GLOBAL_VAR(opt_log_queries_not_using_indexes),
|
||||
CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||
|
||||
static Sys_var_mybool Sys_log_slow_admin_statements(
|
||||
"log_slow_admin_statements",
|
||||
"Log slow OPTIMIZE, ANALYZE, ALTER and other administrative statements to "
|
||||
"the slow log if it is open.",
|
||||
GLOBAL_VAR(opt_log_slow_admin_statements),
|
||||
CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||
|
||||
static Sys_var_mybool Sys_log_slow_slave_statements(
|
||||
"log_slow_slave_statements",
|
||||
"Log slow statements executed by slave thread to the slow log if it is open.",
|
||||
GLOBAL_VAR(opt_log_slow_slave_statements),
|
||||
CMD_LINE(OPT_ARG), DEFAULT(FALSE));
|
||||
|
||||
static Sys_var_ulong Sys_log_warnings(
|
||||
"log_warnings",
|
||||
"Log some not critical warnings to the general log file."
|
||||
|
Loading…
x
Reference in New Issue
Block a user