Capture DatabaseError for deadlock check

Pymysql can raise 'lock wait timeout exceeded' errors
as InternalErrors. The previous filter was only catching
OperationalError exceptions. This patch changes it to
catch all DatabaseErrors, which both of the aforementioned
exceptions inherit.

Change-Id: If7bd1ceef6e5d64f0766b780616388c62862ce82
Closes-Bug: #1608691
This commit is contained in:
Kevin Benton
2016-08-01 13:40:03 -07:00
parent c5999fb2fa
commit 3277ef33f2
2 changed files with 3 additions and 2 deletions

View File

@@ -59,7 +59,7 @@ def filters(dbname, exception_type, regex):
# as well as sqlalchemy.exc.DBAPIError, as SQLAlchemy will reraise it
# as this until issue #3075 is fixed.
@filters("mysql", sqla_exc.OperationalError, r"^.*\b1213\b.*Deadlock found.*")
@filters("mysql", sqla_exc.OperationalError,
@filters("mysql", sqla_exc.DatabaseError,
r"^.*\b1205\b.*Lock wait timeout exceeded.*")
@filters("mysql", sqla_exc.InternalError, r"^.*\b1213\b.*Deadlock found.*")
@filters("postgresql", sqla_exc.OperationalError, r"^.*deadlock detected.*")

View File

@@ -884,7 +884,8 @@ class TestDeadlock(TestsExceptionFilter):
self._run_deadlock_detect_test(
"mysql",
"(1205, 'Lock wait timeout exceeded; "
"try restarting transaction')"
"try restarting transaction')",
orig_exception_cls=self.InternalError
)
def test_mysql_mysqlconnector_deadlock(self):