memory (sqlite): retry _runInteraction in the same way as for _runQuery, this improve reliability

This commit is contained in:
Goffi 2019-01-04 09:21:16 +01:00
commit 610e88841a

View file

@ -140,16 +140,37 @@ class ConnectionPool(adbapi.ConnectionPool):
# Sqlite integration, probably with high level library
retry -= 1
if retry == 0:
log.error(_(u'too many db tries, we abandon! Error message: {msg}').format(
msg = e))
log.error(_(u'too many db tries, we abandon! Error message: {msg}')
.format(msg = e))
raise e
log.warning(_(u'exception while running query, retrying ({try_}): {msg}').format(
log.warning(
_(u'exception while running query, retrying ({try_}): {msg}').format(
try_ = 6 - retry,
msg = e))
kw['query_retry'] = retry
return self._runQuery(trans, *args, **kw)
return trans.fetchall()
def _runInteraction(self, interaction, *args, **kw):
# sometimes interaction may fail while committing in _runInteraction
# and it may be due to a db lock. So we work around it in a similar way
# as for _runQuery but with only 3 tries
retry = kw.pop('interaction_retry', 4)
try:
return adbapi.ConnectionPool._runInteraction(self, interaction, *args, **kw)
except Exception as e:
retry -= 1
if retry == 0:
log.error(
_(u'too many interaction tries, we abandon! Error message: {msg}')
.format(msg = e))
raise e
log.warning(
_(u'exception while running interaction, retrying ({try_}): {msg}')
.format(try_ = 4 - retry, msg = e))
kw['interaction_retry'] = retry
return self._runInteraction(interaction, *args, **kw)
class SqliteStorage(object):
"""This class manage storage with Sqlite database"""