unpredictable log_slow_filter behaviour
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Percona Server moved to https://jira.percona.com/projects/PS |
Fix Released
|
Medium
|
Laurynas Biveinis | ||
5.1 |
Invalid
|
Medium
|
Unassigned | ||
5.5 |
Fix Released
|
Medium
|
Laurynas Biveinis |
Bug Description
log_slow_filter behaviour is a total mess in 5.5.25a-27.1. Tested on debian squeeze package + compiled from src on another machine. Slow log configuration is in attached file. During testing I've manipulated local log_slow_filter var, global remained intact with value as shown in attached file.
Test query plan:
# Query_time: 5.859329 Lock_time: 0.000176 Rows_sent: 393 Rows_examined: 1869321 Rows_affected: 0 Rows_read: 393
# Bytes_sent: 35898 Tmp_tables: 1 Tmp_disk_tables: 0 Tmp_table_sizes: 127040
# InnoDB_trx_id: 3807
# QC_Hit: No Full_scan: No Full_join: No Tmp_table: Yes Tmp_table_on_disk: No
# Filesort: Yes Filesort_on_disk: No Merge_passes: 0
*** full_scan,
logged despite not mathed
*** full_scan
logged despite not matched
*** full_join
not logged, as expected.
however, another statement with plan
# QC_Hit: No Full_scan: Yes Full_join: No Tmp_table: Yes Tmp_table_on_disk: No
# Filesort: Yes Filesort_on_disk: No Merge_passes: 0
was logged while shouldn't
*** tmp_table
not logged despite matched
*** tmp_table_on_disk
logged despite not matched
*** filesort
not logged despite matched
*** filesort_on_disk
logged despite not matched
Also percona_
Related branches
- Stewart Smith (community): Approve
-
Diff: 3690 lines (+1002/-1194)55 files modifiedPercona-Server/mysql-test/include/log_cleanup.inc (+1/-0)
Percona-Server/mysql-test/include/log_start.inc (+0/-16)
Percona-Server/mysql-test/include/log_stop.inc (+0/-7)
Percona-Server/mysql-test/include/percona_slow_extended_error_on_quit.inc (+0/-50)
Percona-Server/mysql-test/include/percona_slow_log_verbosity_grep.inc (+26/-0)
Percona-Server/mysql-test/include/percona_slow_query_log_rate.inc (+5/-10)
Percona-Server/mysql-test/r/mysqld--help-notwin.result (+2/-2)
Percona-Server/mysql-test/r/percona_bug643149.result (+0/-21)
Percona-Server/mysql-test/r/percona_log_slow_admin_statements.result (+0/-35)
Percona-Server/mysql-test/r/percona_log_slow_filter.result (+0/-16)
Percona-Server/mysql-test/r/percona_log_slow_innodb.result (+42/-0)
Percona-Server/mysql-test/r/percona_log_slow_query_plan.result (+268/-0)
Percona-Server/mysql-test/r/percona_log_slow_query_plan_qc.result (+46/-0)
Percona-Server/mysql-test/r/percona_log_slow_slave_statements-innodb.result (+0/-19)
Percona-Server/mysql-test/r/percona_log_slow_slave_statements.result (+0/-45)
Percona-Server/mysql-test/r/percona_log_slow_sp_statements.result (+0/-25)
Percona-Server/mysql-test/r/percona_log_slow_verbosity.result (+0/-16)
Percona-Server/mysql-test/r/percona_long_query_time.result (+0/-33)
Percona-Server/mysql-test/r/percona_min_examined_row_limit.result (+1/-1)
Percona-Server/mysql-test/r/percona_slow_extended_error_on_quit.result (+23/-168)
Percona-Server/mysql-test/r/percona_slow_extended_log_error.result (+0/-10)
Percona-Server/mysql-test/r/percona_slow_query_log_rate.result (+45/-69)
Percona-Server/mysql-test/r/percona_slow_query_log_timestamp_always.result (+0/-41)
Percona-Server/mysql-test/r/percona_slow_query_log_timestamp_precision.result (+0/-18)
Percona-Server/mysql-test/r/percona_slow_query_log_use_global_control.result (+0/-18)
Percona-Server/mysql-test/t/disabled.def (+1/-0)
Percona-Server/mysql-test/t/percona_log_slow_admin_statements.test (+0/-20)
Percona-Server/mysql-test/t/percona_log_slow_filter.test (+0/-26)
Percona-Server/mysql-test/t/percona_log_slow_innodb.test (+82/-0)
Percona-Server/mysql-test/t/percona_log_slow_query_plan.test (+302/-0)
Percona-Server/mysql-test/t/percona_log_slow_query_plan_qc.test (+71/-0)
Percona-Server/mysql-test/t/percona_log_slow_slave_statements-innodb-slave.opt (+0/-1)
Percona-Server/mysql-test/t/percona_log_slow_slave_statements-innodb.test (+0/-42)
Percona-Server/mysql-test/t/percona_log_slow_slave_statements-slave.opt (+0/-1)
Percona-Server/mysql-test/t/percona_log_slow_slave_statements.test (+0/-117)
Percona-Server/mysql-test/t/percona_log_slow_sp_statements.test (+0/-29)
Percona-Server/mysql-test/t/percona_log_slow_verbosity.test (+0/-19)
Percona-Server/mysql-test/t/percona_long_query_time.test (+0/-25)
Percona-Server/mysql-test/t/percona_min_examined_row_limit.test (+0/-35)
Percona-Server/mysql-test/t/percona_slow_extended_error_on_quit.test (+0/-87)
Percona-Server/mysql-test/t/percona_slow_extended_log_error.test (+0/-15)
Percona-Server/mysql-test/t/percona_slow_query_log_rate.test (+10/-3)
Percona-Server/mysql-test/t/percona_slow_query_log_timestamp_always.test (+0/-34)
Percona-Server/mysql-test/t/percona_slow_query_log_timestamp_precision.test (+0/-25)
Percona-Server/mysql-test/t/percona_slow_query_log_use_global_control.test (+0/-28)
Percona-Server/sql/event_scheduler.cc (+0/-1)
Percona-Server/sql/log.cc (+49/-23)
Percona-Server/sql/log_event.cc (+1/-1)
Percona-Server/sql/slave.cc (+1/-2)
Percona-Server/sql/sql_class.cc (+0/-5)
Percona-Server/sql/sql_class.h (+8/-20)
Percona-Server/sql/sql_connect.cc (+0/-8)
Percona-Server/sql/sql_parse.cc (+15/-5)
Percona-Server/sql/sys_vars.cc (+2/-1)
Percona-Server/storage/innobase/handler/ha_innodb.cc (+1/-1)
Changed in percona-server: | |
importance: | Undecided → Medium |
status: | Confirmed → Triaged |
tags: | added: slow-extended |
no longer affects: | percona-server/5.6 |
Changed in percona-server: | |
status: | Triaged → Fix Released |
assignee: | nobody → Laurynas Biveinis (laurynas-biveinis) |
Confirmed that it is broken.
Few instances:
1. If log_slow_ filter= "full_scan" the query is logged even if it is not a full_scan
This is due to a bug:
a)sys_vars.cc:
const char *log_slow_ filter_ name[]= { "qc_miss", "full_scan", "full_join",
"tmp_ table", "tmp_table_ on_disk" , "filesort", "filesort_on_disk", 0};
b)sql_class.h:
#define QPLAN_NONE 0
#define QPLAN_QC 1 << 0
#define QPLAN_QC_NO 1 << 1
#define QPLAN_FULL_SCAN 1 << 2
#define QPLAN_FULL_JOIN 1 << 3
#define QPLAN_TMP_TABLE 1 << 4
#define QPLAN_TMP_DISK 1 << 5
#define QPLAN_FILESORT 1 << 6
#define QPLAN_FILESORT_DISK 1 << 7
c) .log_slow_ filter != 0 && !(thd-> variables. log_slow_ filter & thd->query_ plan_flags) ||
((thd-> variables. log_slow_ filter & SLOG_F_QC_NO) &&
(thd-> query_plan_ flags & QPLAN_QC)))) VOID_RETURN;
/* Follow the slow log filter configuration. */
if (thd->variables
(
DBUG_
So, as you can see the #defines and the set variables are not aligned.
For instance, for a non-table scan simple query with query cache miss thd->query_flags=2 (QPLAN_QC_NO)
But in the set, full_scan = 2 and qc_miss=1,
so
thd->variables. log_slow_ filter & thd->query_ plan_flags = 2 & 2 => !(2 & 2) is false and the query is NOT filtered out.
The fix is simple:
======= ======= ======= ======= ======= ======= ======= ======= === slow_filter { F_TMP_TABLE, SLOG_F_TMP_DISK, SLOG_F_FILESORT,
--- sql/sql_class.h 2012-07-17 22:27:15.000000000 +0530
+++ /tmp/sql_class.h 2012-08-06 04:16:58.041077338 +0530
@@ -80,14 +80,14 @@
SLOG_RT_SESSION, SLOG_RT_QUERY
};
#define QPLAN_NONE 0
-#define QPLAN_QC 1 << 0
-#define QPLAN_QC_NO 1 << 1
-#define QPLAN_FULL_SCAN 1 << 2
-#define QPLAN_FULL_JOIN 1 << 3
-#define QPLAN_TMP_TABLE 1 << 4
-#define QPLAN_TMP_DISK 1 << 5
-#define QPLAN_FILESORT 1 << 6
-#define QPLAN_FILESORT_DISK 1 << 7
+#define QPLAN_QC_NO 1 << 0
+#define QPLAN_FULL_SCAN 1 << 1
+#define QPLAN_FULL_JOIN 1 << 2
+#define QPLAN_TMP_TABLE 1 << 3
+#define QPLAN_TMP_DISK 1 << 4
+#define QPLAN_FILESORT 1 << 5
+#define QPLAN_FILESORT_DISK 1 << 6
+#define QPLAN_QC 1 << 7
enum enum_log_
SLOG_F_QC_NO, SLOG_F_FULL_SCAN, SLOG_F_FULL_JOIN,
SLOG_
--- sql/sql_parse.cc 2012-07-17 22:27:15.000000000 +0530 .log_slow_ filter != 0 &&
(!(thd- >variables. log_slow_ filter & thd->query_ plan_flags) || variables. log_slow_ filter & SLOG_F_QC_NO) && variables. log_slow_ filter & QPLAN_QC_NO) &&
(thd- >query_ plan_flags & QPLAN_QC)))) VOID_RETURN;
+++ /tmp/sql_parse.cc 2012-08-06 04:26:48.177788229 +0530
@@ -1534,7 +1534,7 @@
/* Follow the slow log filter configuration. */
if (thd->variables
- ((thd->
+ ((thd->
DBUG_
======= ======= ======= ======= ======= ======= ======= ======= ======= ==
(The enum enum_log_ slow_filter is also not required and can be removed)
2. If log_filter is anything that is not full_scan, the query is not logged (even if it doesn't belong in any categories above) for same reason as above.