SET STATEMENT does not work with slow log tuning (long_query_time, log_slow_filter, log_slow_verbosity, log_slow_rate_limit)

Bug #1388632 reported by Elena Stepanova
8
This bug affects 1 person
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://bugs.launchpad.net/percona-server/+bug/1388526 for min_examined_row_limit.

##################################
# Test case 1 (SET STATEMENT)

--let $slowlog = `select @@slow_query_log_file`

set @log_output.saved = @@global.log_output;
set @slow_query_log.saved = @@global.slow_query_log;

set global log_output = 'FILE', global slow_query_log = 1;
set long_query_time = 10;

--connect (con1,localhost,root,,)

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_log.saved;

##################################
# Test case 2 (SET)

--let $slowlog = `select @@slow_query_log_file`

set @log_output.saved = @@global.log_output;
set @slow_query_log.saved = @@global.slow_query_log;

set global log_output = 'FILE', global slow_query_log = 1;
set long_query_time = 10;

--connect (con1,localhost,root,,)

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_log.saved;

################################################

Final log for the 1st test case:

/data/repo/bzr/percona-5.6/sql/mysqld, Version: 5.6.21-69.0-debug-log (Source distribution). started with:
Tcp port: 13001 Unix socket: /data/repo/bzr/percona-5.6/mysql-test/var/tmp/mysqld.1.sock
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=1414961771;
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=1414961772;
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=1414961772;
set statement LOG_SLOW_RATE_LIMIT = 4 for select sleep(0.16);

################################################

Final log for the 2nd test case:

/data/repo/bzr/percona-5.6/sql/mysqld, Version: 5.6.21-69.0-debug-log (Source distribution). started with:
Tcp port: 13001 Unix socket: /data/repo/bzr/percona-5.6/mysql-test/var/tmp/mysqld.1.sock
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=1414961322;
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=1414961322;
select host, sleep(0.15) from mysql.user where user = 'root';

Elena Stepanova (elenst)
description: updated
tags: added: set-statement
Revision history for this message
Nilnandan Joshi (nilnandan-joshi) wrote :
Download full text (6.9 KiB)

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
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/mysql-test/var'...
Installing system database...

==============================================================================

TEST RESULT TIME (ms) or COMMENT
--------------------------------------------------------------------------

worker[1] Using MTR_BUILD_THREAD 300, with reserved ports 13000..13009
worker[1] mysql-test-run: WARNING: running this script as _root_ will cause some tests to be skipped
set @log_output.saved = @@global.log_output;
set @slow_query_log.saved = @@global.slow_query_log;
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/mysql-test/var/tmp/mysqld.1.sock
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/mysql-test/var/tmp/mysqld.1.sock
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=1416909362;
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/mysql-test/var/tmp/mysqld.1.sock
Time Id Command Argument
# Time: 141125 12:56:02
# User@Host: root[r...

Read more...

Revision history for this message
Shahriyar Rzayev (rzayev-sehriyar) wrote :

Percona now uses JIRA for bug reports so this bug report is migrated to: https://jira.percona.com/browse/PS-1578

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.