Commit 49e7d17f authored by Julien Muchembled's avatar Julien Muchembled

neolog: do not die when a table is corrupted

parent ad379295
...@@ -107,20 +107,37 @@ class Log(object): ...@@ -107,20 +107,37 @@ class Log(object):
self._reload(p[0]) self._reload(p[0])
except StopIteration: except StopIteration:
p = None p = None
except sqlite3.DatabaseError, e:
yield time.time(), None, 'PACKET', self._exc(e)
p = None
try:
for date, name, cluster, nid, level, pathname, lineno, msg in nl: for date, name, cluster, nid, level, pathname, lineno, msg in nl:
while p and p[0] < date: while p and p[0] < date:
yield self._packet(*p) yield self._packet(*p)
try:
p = next(np, None) p = next(np, None)
except sqlite3.DatabaseError, e:
yield time.time(), None, 'PACKET', self._exc(e)
p = None
self._log_date = date self._log_date = date
yield (date, self._node(name, cluster, nid), yield (date, self._node(name, cluster, nid),
getLevelName(level), msg.splitlines()) getLevelName(level), msg.splitlines())
except sqlite3.DatabaseError, e:
yield time.time(), None, 'LOG', self._exc(e)
if p: if p:
yield self._packet(*p) yield self._packet(*p)
try:
for p in np: for p in np:
yield self._packet(*p) yield self._packet(*p)
except sqlite3.DatabaseError, e:
yield time.time(), None, 'PACKET', self._exc(e)
finally: finally:
self._db.rollback() self._db.rollback()
@staticmethod
def _exc(e):
return ('%s: %s' % (type(e).__name__, e)).splitlines()
def _node(self, name, cluster, nid): def _node(self, name, cluster, nid):
if nid and not self._no_nid: if nid and not self._no_nid:
name = self.uuid_str(nid) name = self.uuid_str(nid)
......
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