Commit 16fdb24d authored by Julien Muchembled's avatar Julien Muchembled

Fix log corruption on rotation in multi-threaded applications (e.g. client)

Corrupted logs cause neolog to fail with the following error:

  AttributeError: 'Log' object has no attribute 'uuid_str'
parent 243c1a0f
...@@ -206,10 +206,10 @@ class NEOLogger(Logger): ...@@ -206,10 +206,10 @@ class NEOLogger(Logger):
x = q("SELECT text FROM protocol ORDER BY date DESC LIMIT 1" x = q("SELECT text FROM protocol ORDER BY date DESC LIMIT 1"
).fetchone() ).fetchone()
if (x and x[0]) != p: if (x and x[0]) != p:
try: # In case of multithreading, we can have locally unsorted
x = self._record_queue[0].created # records so we can't find the oldest one (it may not be
except IndexError: # pushed to queue): let's use 0 on log rotation.
x = time() x = time() if x else 0
q("INSERT INTO protocol VALUES (?,?)", (x, p)) q("INSERT INTO protocol VALUES (?,?)", (x, p))
self._db.commit() self._db.commit()
self._node = {x[1:]: x[0] for x in q("SELECT * FROM node")} self._node = {x[1:]: x[0] for x in q("SELECT * FROM node")}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment