Merge "Check for mysql SAVEPOINT error in retry decorator"
This commit is contained in:
commit
f98a4fa0a2
|
@ -37,7 +37,10 @@ MAX_RETRIES = 10
|
|||
|
||||
|
||||
def is_retriable(e):
|
||||
return _is_nested_instance(e, (db_exc.DBDeadlock, exc.StaleDataError))
|
||||
if _is_nested_instance(e, (db_exc.DBDeadlock, exc.StaleDataError)):
|
||||
return True
|
||||
# looking savepoints mangled by deadlocks. see bug/1590298 for details.
|
||||
return _is_nested_instance(e, db_exc.DBError) and '1305' in str(e)
|
||||
|
||||
is_deadlock = moves.moved_function(is_retriable, 'is_deadlock', __name__,
|
||||
message='use "is_retriable" instead',
|
||||
|
|
|
@ -82,3 +82,8 @@ class TestDeadLockDecorator(base.BaseTestCase):
|
|||
e = exceptions.MultipleExceptions([ValueError(), db_exc.DBDeadlock()])
|
||||
with testtools.ExpectedException(exceptions.MultipleExceptions):
|
||||
self._decorated_function(db_api.MAX_RETRIES + 1, e)
|
||||
|
||||
def test_mysql_savepoint_error(self):
|
||||
e = db_exc.DBError("(pymysql.err.InternalError) (1305, u'SAVEPOINT "
|
||||
"sa_savepoint_1 does not exist')")
|
||||
self.assertIsNone(self._decorated_function(1, e))
|
||||
|
|
Loading…
Reference in New Issue