SET STATEMENT does not work with slow log tuning (long_query_time, log_slow_filter, log_slow_verbosity, log_slow_rate_limit)
Affects | Status | Importance | Assigned to | Milestone | ||
---|---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS | Status tracked in 5.7 | |||||
5.6 |
Triaged
|
Medium
|
Unassigned | |||
5.7 |
Triaged
|
Medium
|
Unassigned |
Bug Description
The first test case is for 4 options each set via SET STATEMENT var FOR query. Every part of the test fails -- whatever is expected does not happen.
To make sure that the test itself is valid, the second test case is provided. It does exactly the same, but via old-fashioned SET var; query; unset var. It works as expected.
The second connection in the test is used to avoid side effects of the other bugs.
See also https:/
#######
# Test case 1 (SET STATEMENT)
--let $slowlog = `select @@slow_
set @log_output.saved = @@global.
set @slow_query_
set global log_output = 'FILE', global slow_query_log = 1;
set long_query_time = 10;
--connect (con1,localhost
set statement LONG_QUERY_TIME = 0.01 for select sleep(0.11);
--echo #------
--echo # The last set statement is expected to be in the log
--echo #------
cat_file $slowlog;
--echo #------
set long_query_time = 0.01;
set statement LOG_SLOW_FILTER = 'full_scan' for select sleep(0.14);
--echo #------
--echo # The last set statement is NOT expected to be in the log
--echo #------
cat_file $slowlog;
--echo #------
set statement LOG_SLOW_VERBOSITY = 'innodb' for select host, sleep(0.15) from mysql.user where user = 'root';
--echo #------
--echo # The last set statement should have something about InnoDB stats
--echo #------
cat_file $slowlog;
--echo #------
set statement LOG_SLOW_RATE_LIMIT = 4 for select sleep(0.16);
--echo #------
--echo # The last set statement is NOT expected to be in the log
--echo #------
cat_file $slowlog;
--echo #------
--disconnect con1
--connection default
set global log_output = @log_output.saved;
set global slow_query_log = @slow_query_
#######
# Test case 2 (SET)
--let $slowlog = `select @@slow_
set @log_output.saved = @@global.
set @slow_query_
set global log_output = 'FILE', global slow_query_log = 1;
set long_query_time = 10;
--connect (con1,localhost
set LONG_QUERY_TIME = 0.01;
select sleep(0.11);
set LONG_QUERY_TIME = DEFAULT;
--echo #------
--echo # The last select statement is expected to be in the log
--echo #------
cat_file $slowlog;
--echo #------
set long_query_time = 0.01;
set LOG_SLOW_FILTER = 'full_scan';
select sleep(0.14);
set LOG_SLOW_FILTER = DEFAULT;
--echo #------
--echo # The last select statement is NOT expected to be in the log
--echo #------
cat_file $slowlog;
--echo #------
set LOG_SLOW_VERBOSITY = 'innodb';
select host, sleep(0.15) from mysql.user where user = 'root';
set LOG_SLOW_VERBOSITY = DEFAULT;
--echo #------
--echo # The last select statement should have something about InnoDB stats
--echo #------
cat_file $slowlog;
--echo #------
set LOG_SLOW_RATE_LIMIT = 4;
select sleep(0.16);
set LOG_SLOW_RATE_LIMIT = DEFAULT;
--echo #------
--echo # The last select statement is NOT expected to be in the log
--echo #------
cat_file $slowlog;
--echo #------
--disconnect con1
--connection default
set global log_output = @log_output.saved;
set global slow_query_log = @slow_query_
#######
Final log for the 1st test case:
/data/repo/
Tcp port: 13001 Unix socket: /data/repo/
Time Id Command Argument
# Time: 141102 23:56:11
# User@Host: root[root] @ localhost [] Id: 3
# Schema: test Last_errno: 0 Killed: 0
# Query_time: 0.140614 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 Rows_affected: 0
# Bytes_sent: 66
use test;
SET timestamp=
set statement LOG_SLOW_FILTER = 'full_scan' for select sleep(0.14);
# Time: 141102 23:56:12
# User@Host: root[root] @ localhost [] Id: 3
# Schema: test Last_errno: 0 Killed: 0
# Query_time: 0.602489 Lock_time: 0.000316 Rows_sent: 4 Rows_examined: 4 Rows_affected: 0
# Bytes_sent: 165
SET timestamp=
set statement LOG_SLOW_VERBOSITY = 'innodb' for select host, sleep(0.15) from mysql.user where user = 'root';
# User@Host: root[root] @ localhost [] Id: 3
# Schema: test Last_errno: 0 Killed: 0
# Query_time: 0.161236 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 Rows_affected: 0
# Bytes_sent: 66
SET timestamp=
set statement LOG_SLOW_RATE_LIMIT = 4 for select sleep(0.16);
#######
Final log for the 2nd test case:
/data/repo/
Tcp port: 13001 Unix socket: /data/repo/
Time Id Command Argument
# Time: 141102 23:48:42
# User@Host: root[root] @ localhost [] Id: 3
# Schema: test Last_errno: 0 Killed: 0
# Query_time: 0.113348 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 Rows_affected: 0
# Bytes_sent: 66
use test;
SET timestamp=
select sleep(0.11);
# User@Host: root[root] @ localhost [] Id: 3
# Schema: test Last_errno: 0 Killed: 0
# Query_time: 0.601798 Lock_time: 0.000317 Rows_sent: 4 Rows_examined: 4 Rows_affected: 0
# Bytes_sent: 165
# No InnoDB statistics available for this query
SET timestamp=
select host, sleep(0.15) from mysql.user where user = 'root';
Able to reproduce the same with MySQL/PS 5.6.21 and 1st test case.
root@Dell- XPS:/usr/ share/mysql- test# ./mysql-test-run.pl bug1388632 mysql-test/ var'...
Logging: ./mysql-test-run.pl bug1388632
2014-11-25 15:25:59 24478 [Note] Plugin 'FEDERATED' is disabled.
2014-11-25 15:25:59 24478 [Note] Binlog end
2014-11-25 15:25:59 24478 [Note] Shutting down plugin 'MyISAM'
2014-11-25 15:25:59 24478 [Note] Shutting down plugin 'CSV'
MySQL Version 5.6.21
Checking supported features...
- SSL connections supported
Collecting tests...
Checking leftover processes...
Removing old var directory...
Creating var directory '/usr/share/
Installing system database...
======= ======= ======= ======= ======= ======= ======= ======= ======= ======= ======= =
TEST RESULT TIME (ms) or COMMENT ------- ------- ------- ------- ------- ------- ------- ------- ------- ----
-------
worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009 log_output; log.saved = @@global. slow_query_ log; ------- ------- ------- ------- ------- ------- ------- ------- ------ mysql-test/ var/tmp/ mysqld. 1.sock ------- ------- ------- ------- ------- ------- ------- ------- ------ ------- ------- ------- ------- ------- ------- ------- ------- ------ mysql-test/ var/tmp/ mysqld. 1.sock 1416909362; ------- ------- ------- ------- ------- ------- ------- ------- ------ ------- ------- ------- ------- ------- ------- ------- ------- ------ mysql-test/ var/tmp/ mysqld. 1.sock
worker[1] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
set @log_output.saved = @@global.
set @slow_query_
set global log_output = 'FILE', global slow_query_log = 1;
set long_query_time = 10;
set statement LONG_QUERY_TIME = 0.01 for select sleep(0.11);
sleep(0.11)
0
#------
# The last set statement is expected to be in the log
#------
/usr/sbin/mysqld, Version: 5.6.21-70.1-log (Percona Server (GPL), Release 70.1, Revision 698). started with:
Tcp port: 13001 Unix socket: /usr/share/
Time Id Command Argument
#------
set long_query_time = 0.01;
set statement LOG_SLOW_FILTER = 'full_scan' for select sleep(0.14);
sleep(0.14)
0
#------
# The last set statement is NOT expected to be in the log
#------
/usr/sbin/mysqld, Version: 5.6.21-70.1-log (Percona Server (GPL), Release 70.1, Revision 698). started with:
Tcp port: 13001 Unix socket: /usr/share/
Time Id Command Argument
# Time: 141125 12:56:02
# User@Host: root[root] @ localhost [] Id: 3
# Schema: test Last_errno: 0 Killed: 0
# Query_time: 0.140294 Lock_time: 0.000000 Rows_sent: 1 Rows_examined: 0 Rows_affected: 0
# Bytes_sent: 66
use test;
SET timestamp=
set statement LOG_SLOW_FILTER = 'full_scan' for select sleep(0.14);
#------
set statement LOG_SLOW_VERBOSITY = 'innodb' for select host, sleep(0.15) from mysql.user where user = 'root';
host sleep(0.15)
127.0.0.1 0
::1 0
dell-xps 0
localhost 0
#------
# The last set statement should have something about InnoDB stats
#------
/usr/sbin/mysqld, Version: 5.6.21-70.1-log (Percona Server (GPL), Release 70.1, Revision 698). started with:
Tcp port: 13001 Unix socket: /usr/share/
Time Id Command Argument
# Time: 141125 12:56:02
# User@Host: root[r...