Occasional erros in the mysql driver
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
tooz |
New
|
Undecided
|
Unassigned |
Bug Description
Hello,
We are getting the following error in gnocchi:
2018-12-13 10:01:05,723 [3173] ERROR cotyledon._utils: Unhandled exception
Traceback (most recent call last):
File "/usr/lib/
yield
File "/usr/lib/
self.run()
File "/usr/lib/
self._run_job()
File "/usr/lib/
lock.release()
File "/usr/lib/
cause=e)
File "/usr/lib/
excutils.
File "/usr/lib/
six.
File "/usr/lib/
raise value
ToozError: (0, '')
I looked around the source code and I suspect that this is caused by a leaked mysql cursor. Tooz creates cursors using `with self._conn as cur:`.
However, if you look at the source code of PyMySQL you will see that the connection doesn't close the cursor:
https:/
The proper way of using cursors is exemplified in the PyMySQL examples:
with connection.cursor() as cursor:
# do stuff
The fix would be to replace `with self._conn as cur:` with
`with self._conn.cursor() as cur:` in the mysql driver.
description: | updated |