mysql support is broken
bang-uin opened this issue · 1 comments
Hi,
the mysql support seems to be broken.
The function def login_successful(self, sensor):
in output-mysql.py
uses self.db.runQuery
but should use self.server.runQuery
.
Beside from that the deferred queries aren't working.
To make them work add import from twisted.internet import defer
at the top and @defer.inlineCallbacks
above the function definition def login_successful(self, sensor)
But even with that it breaks on the queries itself.
Please have a look.
Btw.: The sensor_name used in the docker configuration is not used in the queries. Instead the container id is used, which breaks the mysql name
column definition in table sensors
.
2016-11-03T22:30:38+0100 [-] Unhandled Error
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/twisted/application/app.py", line 395, in startReactor
self.config, oldstdout, oldstderr, self.profiler, reactor)
File "/usr/local/lib/python2.7/dist-packages/twisted/application/app.py", line 310, in runReactorWithLogging
reactor.run()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 1195, in run
self.mainLoop()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 1204, in mainLoop
self.runUntilCurrent()
--- <exception caught here> ---
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/base.py", line 798, in runUntilCurrent
f(*a, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 454, in callback
assert not isinstance(result, Deferred)
exceptions.AssertionError:
2016-11-03T22:30:38+0100 [HonsshServerTransport,1,192.168.100.215] [PLUGIN][OUTPUT-MYSQL] - CHANNEL_OPENED
2016-11-03T22:30:38+0100 [HonsshServerTransport,1,192.168.100.215] [PLUGIN][OUTPUT-TXTLOG] - CHANNEL_OPENED
2016-11-03T22:30:39+0100 [twisted.internet.defer#critical] Unhandled error in Deferred:
2016-11-03T22:30:39+0100 [twisted.internet.defer#critical]
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 496, in errback
self._startRunCallbacks(fail)
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 563, in _startRunCallbacks
self._runCallbacks()
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 649, in _runCallbacks
current.result = callback(current.result, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1316, in gotResult
_inlineCallbacks(r, g, deferred)
--- <exception caught here> ---
File "/usr/local/lib/python2.7/dist-packages/twisted/internet/defer.py", line 1258, in _inlineCallbacks
result = result.throwExceptionIntoGenerator(g)
File "/usr/local/lib/python2.7/dist-packages/twisted/python/failure.py", line 389, in throwExceptionIntoGenerator
return g.throw(self.type, self.value, self.tb)
File "/home/potty/honssh/honssh/output/output-mysql.py", line 83, in login_successful
r = yield self.server.runQuery('SELECT `id` FROM `clients` WHERE `version` = %s', (session['version']))
File "/usr/local/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 246, in inContext
result = inContext.theWork()
File "/usr/local/lib/python2.7/dist-packages/twisted/python/threadpool.py", line 262, in <lambda>
inContext.theWork = lambda: context.call(ctx, func, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 118, in callWithContext
return self.currentContext().callWithContext(ctx, func, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/python/context.py", line 81, in callWithContext
return func(*args,**kw)
File "/home/potty/honssh/kippo/dblog/mysql.py", line 48, in _runInteraction
self, interaction, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/enterprise/adbapi.py", line 477, in _runInteraction
compat.reraise(excValue, excTraceback)
File "/usr/local/lib/python2.7/dist-packages/twisted/enterprise/adbapi.py", line 467, in _runInteraction
result = interaction(trans, *args, **kw)
File "/usr/local/lib/python2.7/dist-packages/twisted/enterprise/adbapi.py", line 481, in _runQuery
trans.execute(*args, **kw)
File "/usr/lib/python2.7/dist-packages/MySQLdb/cursors.py", line 210, in execute
query = query % args
exceptions.TypeError: not all arguments converted during string formatting
Here is another issue about duplicate primary keys (maybe a second issue should be raised for that):
2016-11-03 22:42:55+0100 [-] [PLUGIN][MYSQL] - SQL Error:(1062, "Duplicate entry '2016-11-03 22:42:55-asd@123456789-root-0' for key 'PRIMARY'")
Fixed - hopefully 😄