Bug #85449 SlowQueryLog parser not working with MySQL 5.7 slow query log

Submitted: 14 Mar 2017 15:53 Modified: 15 Mar 2017 5:14
Reporter: Hugo Dubois Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Utilities Severity:S3 (Non-critical)
Version:1.6.5 OS:Any
Assigned to: CPU Architecture:Any
Tags: parser, utilities

[14 Mar 2017 15:53] Hugo Dubois
Description:
SlowQueryLog from mysql.utilities.common.parser fails to parse MySQL 5.7 slowquery log:

Traceback (most recent call last):
  File "./test.py", line 16, in <module>
    for entry in log:
  File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 251, in next
    entry = self._parse_entry()
  File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 716, in _parse_entry
    self._parse_timestamp(line, entry)
  File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 609, in _parse_timestamp
    info = self._parse_line(_SLOW_TIMESTAMP_CRE, line)
  File "/usr/lib/python2.7/site-packages/mysql/utilities/common/parser.py", line 570, in _parse_line
    line[:30])
mysql.utilities.exception.LogParserError: ('Failed parsing Slow Query line: # Time: 2017-03-14T16:00:40.16', 0)

How to repeat:
Try to parse MySQL 5.7 slow query log with this basic script: 

#!/usr/bin/env python

from mysql.utilities.common.parser import SlowQueryLog

if __name__ == '__main__':

  slow_file = "/pathToLogFile/slowquery.log"
  slow_log = open(slow_file)

  log = SlowQueryLog(slow_log)

  for entry in log:
    for k, v in entry.iteritems():
      print k, v

No issue with MySQL 5.6 slow query log. Time field in slow query log has changed between 5.6 and 5.7:

5.6:
# Time: 170312  3:33:02

5.7:
# Time: 2017-03-14T16:00:40.165473+01:00
[15 Mar 2017 5:14] MySQL Verification Team
Hello Hugo Dubois,

Thank you for the report.
Verified as described.

Thanks,
Umesh

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.