log_slow_rate_limit logs all queries on a connection after a >1s query

Bug #375494 reported by Morgan Tocker
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Percona patches
Fix Released
High
Unassigned

Bug Description

The log_slow_rate_limit should not log queries from all connections, but it seems that after a 1 second threshold is tripped, all slow queries from that session can potentially be logged.

To reproduce, set a my.cnf file to have something like:

log_slow_rate_limit=4
log_slow_verbosity=innodb,query_plan
long_query_time=0
log-slow-queries=/tmp/slow-log.log
log_queries_not_using_indexes=1

Then connect to the server:

$ mysql test

mysql> create table my_test (a int); # not logged
Query OK, 0 rows affected (0.01 sec)

mysql> select 1; # not logged
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

mysql> insert into my_test VALUES (SLEEP(1)); # logged!
Query OK, 1 row affected (1.01 sec)

mysql> select 1; # logged!
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

It seems to be anything over that one second threshold. Here was my original testcase:

mysql> create table t1 (id int not null primary key auto_increment, b char(255));
Query OK, 0 rows affected (0.82 sec)

mysql> insert into t1 VALUES (NULL, REPEAT('a', 255));
Query OK, 1 row affected (0.00 sec)

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 1 row affected (0.00 sec)
Records: 1 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 2 rows affected (0.00 sec)
Records: 2 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 4 rows affected (0.00 sec)
Records: 4 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 8 rows affected (0.00 sec)
Records: 8 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 16 rows affected (0.00 sec)
Records: 16 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 32 rows affected (0.00 sec)
Records: 32 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 64 rows affected (0.00 sec)
Records: 64 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 128 rows affected (0.00 sec)
Records: 128 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 256 rows affected (0.00 sec)
Records: 256 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 512 rows affected (0.00 sec)
Records: 512 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 1024 rows affected (0.00 sec)
Records: 1024 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 2048 rows affected (0.01 sec)
Records: 2048 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 4096 rows affected (0.02 sec)
Records: 4096 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 8192 rows affected (0.05 sec)
Records: 8192 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 16384 rows affected (0.13 sec)
Records: 16384 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 32768 rows affected (0.23 sec)
Records: 32768 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1;
Query OK, 65536 rows affected (0.47 sec)
Records: 65536 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1; # logged
Query OK, 131072 rows affected (1.02 sec)
Records: 131072 Duplicates: 0 Warnings: 0

mysql> insert into t1 SELECT NULL, REPEAT('a', 255) FROM t1; # logged
Query OK, 262144 rows affected (2.03 sec)
Records: 262144 Duplicates: 0 Warnings: 0

mysql> SELECT 1; # logged
+---+
| 1 |
+---+
| 1 |
+---+
1 row in set (0.00 sec)

Morgan Tocker (morgo)
summary: - log_slow_rate_limit logs all connections after a query > 1s runs
+ log_slow_rate_limit logs all queries on a connection after a >1s query
Changed in percona-patches:
importance: Undecided → Low
status: New → Confirmed
Changed in percona-patches:
assignee: nobody → Yasufumi Kinoshita (yasufumi-kinoshita)
importance: Low → High
Changed in percona-patches:
status: Confirmed → Fix Committed
Changed in percona-patches:
status: Fix Committed → Fix Released
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.