summaryrefslogtreecommitdiff
path: root/sql/sql_parse.cc
diff options
context:
space:
mode:
authorTatjana Azundris Nuernberg <tatjana.nuernberg@oracle.com>2012-02-19 03:18:49 +0000
committerTatjana Azundris Nuernberg <tatjana.nuernberg@oracle.com>2012-02-19 03:18:49 +0000
commit5e6b6c5ea126ce73e236bf23a779947c5e341f56 (patch)
tree9d7170183db986817bf9c46c0ffeaacb2d4e160a /sql/sql_parse.cc
parent1141631802c7ac8caa6ae681ba75e059cc46ade8 (diff)
downloadmariadb-git-5e6b6c5ea126ce73e236bf23a779947c5e341f56.tar.gz
BUG 13454045 - 63524: BUG #35396 "ABNORMAL/IMPOSSIBLE/LARGE QUERY_TIME AND LOCK_TIME" HAPPENS A
If a query's end time is before before its start time, the system clock has been turn back (daylight savings time etc.). When the system clock is changed, we can't tell for certain a given query was actually slow. We did not protect against logging such a query with a bogus execution time (resulting from end_time - start_time being negative), and possibly logging it even though it did not really take long to run. We now have a sanity check in place. sql/sql_parse.cc: Make sure end time is not before start time - otherwise, we can be SURE the system clock was changed in between, but not by how much. In other words, when the clock is changed, we don't know how long a query ran, and whether it was slow.
Diffstat (limited to 'sql/sql_parse.cc')
-rw-r--r--sql/sql_parse.cc5
1 files changed, 3 insertions, 2 deletions
diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc
index 989c3e0f42f..0f190809ab9 100644
--- a/sql/sql_parse.cc
+++ b/sql/sql_parse.cc
@@ -1734,8 +1734,9 @@ void log_slow_statement(THD *thd)
ulonglong end_utime_of_query= thd->current_utime();
thd_proc_info(thd, "logging slow query");
- if (((end_utime_of_query - thd->utime_after_lock) >
- thd->variables.long_query_time ||
+ if ((((end_utime_of_query > thd->utime_after_lock) &&
+ ((end_utime_of_query - thd->utime_after_lock) >
+ thd->variables.long_query_time)) ||
((thd->server_status &
(SERVER_QUERY_NO_INDEX_USED | SERVER_QUERY_NO_GOOD_INDEX_USED)) &&
opt_log_queries_not_using_indexes &&