Bug #71231 Lock_time not correct in slow query log
Submitted: 25 Dec 2013 22:56 Modified: 26 Jan 2014 18:02
Reporter: Toni Sanavullah Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.5.23 OS:Linux
Assigned to: CPU Architecture:Any
Tags: Lock_time, slow query log

[25 Dec 2013 22:56] Toni Sanavullah
Description:
All my tables are MyISAM and the update is causing table lock.  My stored procedures are waiting, then timing out.  Even though they were locked and timed out without finishing their job, the Lock_time seems to be very low.

Linux xxxxxxhost 3.0.26-0.7-default #1 SMP Tue Apr 17 10:27:57 UTC 2012 (3829766) x86_64 x86_64 x86_64 GNU/Linux

mysql> select version();
+------------+
| version()  |
+------------+
| 5.5.23-log |
+------------+
1 row in set (0.00 sec)

# Time: 131224 15:18:35
# User@Host: Toni[Toni] @ myhost [myipaddress]
# Query_time: 134.412257  Lock_time: 0.000091 Rows_sent: 0  Rows_examined: 0
SET timestamp=1387898315;
call mydb.mystps('2013-12-23 00:00:00' , '2013-12-28 00:00:00', '', '', 0);
# User@Host: Toni[Toni] @ myhost [myipaddress]
# Query_time: 132.370270  Lock_time: 0.000091 Rows_sent: 0  Rows_examined: 0
SET timestamp=1387898315;
call mydb.mystps('2013-12-23 00:00:00' , '2013-12-28 00:00:00', '', '', 0);
# User@Host: Toni[Toni] @ myhost [myipaddress]
# Query_time: 135.576004  Lock_time: 0.000089 Rows_sent: 0  Rows_examined: 0
SET timestamp=1387898315;
call mydb.mystps('2013-12-23 00:00:00' , '2013-12-28 00:00:00', '', '', 0);
# User@Host: Toni[Toni] @ myhost [myipaddress]
# Query_time: 133.167910  Lock_time: 0.000087 Rows_sent: 0  Rows_examined: 0
SET timestamp=1387898315;
call mydb.mystps('2013-12-01 00:00:00' , '2014-01-01 00:00:00', '', '', 0);
# User@Host: Toni[Toni] @ myhost [myipaddress]
# Query_time: 137.359866  Lock_time: 0.000088 Rows_sent: 0  Rows_examined: 0

How to repeat:
1. Set the slow query variables
+---------------------+----------------------------------------+
| Variable_name       | Value                                  |
+---------------------+----------------------------------------+
| log_slow_queries    | ON                                     |
| long_query_time     | 5                                      |
| slow_launch_time    | 2                                      |
| slow_query_log      | ON                                     |
| slow_query_log_file | slow.queries.log                       |
+---------------------+----------------------------------------+

2. Create MyISAM table
3. Insert 3M rows
3. Select * from the table
4. Quickly open another session and do update all on the same table 
5. Quickly open another session and try to select a few rows from the same table
6. Look at the slow query for Lock_time

Suggested fix:
Lock_time should reflect true waiting time to obtain a lock.

"The lock_time is the time spent waiting for a lock" as described in MySQL forum: http://forums.mysql.com/read.php?35,377522,378908
[26 Dec 2013 18:02] Sveta Smirnova
Thank you for the report.

I can not repeat described behavior with current version 5.5.35:

# User@Host: root[root] @ localhost [127.0.0.1]
# Query_time: 906.043085  Lock_time: 905.902430 Rows_sent: 1  Rows_examined: 1
SET timestamp=1388080718;
select * from t1 limit 1;

Please upgrade to current version, try with it and if problem still exists provide definition of stored procedure you actually call.
[27 Jan 2014 1:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".