Bug #45442 Pre-log slow queries to make the log useful when MySQL crashes
Submitted: 11 Jun 2009 8:24 Modified: 11 Jun 2009 10:27
Reporter: Stephen Brownlow Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Logging Severity:S4 (Feature request)
Version: OS:Any
Assigned to: CPU Architecture:Any
Tags: crash, pre-log, slow query log

[11 Jun 2009 8:24] Stephen Brownlow
Description:
I would really like to see slow queries logged as soon as they have taken the minimum time, then another time stamp when they have finished.

That way, if the server stops during or because of a slow query, you can easily find that query in the slow query log.

I'm not certain about newer releases of MySQL, but in version 4.0 you won't see the problem query in the log if the server crashes or is restarted because of that query.

How to repeat:
Start a slow query and let it run for the required number of seconds to be classed as a slow query.
Stop the server before the SQL completes.
Look at the Slow query log and the offending SQL is not there.

Suggested fix:
Write an entry to the slow query log as soon as a query has taken the minimum time. 
Then write another time stamp to the log when it has finished.
[11 Jun 2009 10:27] Valeriy Kravchuk
Thank you for the feature request.