comparison sat/memory/sqlite.py @ 2889:28fe69b87ba4

core (memory/sqlite): display arguments in logs in case of too many db/interaction tries
author Goffi <goffi@goffi.org>
date Sun, 07 Apr 2019 18:38:18 +0200
parents a425c1ca51d0
children 1a23547f95fd
comparison
equal deleted inserted replaced
2888:e3803ae89fbc 2889:28fe69b87ba4
148 # FIXME: in case of error, we retry a couple of times 148 # FIXME: in case of error, we retry a couple of times
149 # this is a workaround, we need to move to better 149 # this is a workaround, we need to move to better
150 # Sqlite integration, probably with high level library 150 # Sqlite integration, probably with high level library
151 retry -= 1 151 retry -= 1
152 if retry == 0: 152 if retry == 0:
153 log.error(_(u'too many db tries, we abandon! Error message: {msg}') 153 log.error(_(u'too many db tries, we abandon! Error message: {msg}\n'
154 .format(msg = e)) 154 u'query was {query}'
155 .format(msg=e, query=u' '.join([unicode(a) for a in args]))))
155 raise e 156 raise e
156 log.warning( 157 log.warning(
157 _(u'exception while running query, retrying ({try_}): {msg}').format( 158 _(u'exception while running query, retrying ({try_}): {msg}').format(
158 try_ = 6 - retry, 159 try_ = 6 - retry,
159 msg = e)) 160 msg = e))
170 return adbapi.ConnectionPool._runInteraction(self, interaction, *args, **kw) 171 return adbapi.ConnectionPool._runInteraction(self, interaction, *args, **kw)
171 except Exception as e: 172 except Exception as e:
172 retry -= 1 173 retry -= 1
173 if retry == 0: 174 if retry == 0:
174 log.error( 175 log.error(
175 _(u'too many interaction tries, we abandon! Error message: {msg}') 176 _(u'too many interaction tries, we abandon! Error message: {msg}\n'
176 .format(msg = e)) 177 u'interaction was {args}'
178 .format(msg=e, args=u' '.join([unicode(a) for a in args]))))
177 raise e 179 raise e
178 log.warning( 180 log.warning(
179 _(u'exception while running interaction, retrying ({try_}): {msg}') 181 _(u'exception while running interaction, retrying ({try_}): {msg}')
180 .format(try_ = 4 - retry, msg = e)) 182 .format(try_ = 4 - retry, msg = e))
181 kw['interaction_retry'] = retry 183 kw['interaction_retry'] = retry