Bug #85449 SlowQueryLog parser not working with MySQL 5.7 slow query log
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
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.
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