diff options
author | Kevin Benton <kevin@benton.pub> | 2016-08-01 13:40:03 -0700 |
---|---|---|
committer | Kevin Benton <kevin@benton.pub> | 2016-08-02 09:50:31 -0700 |
commit | 7b633804c5e8269a461e80fa1a27ddb7106e5405 (patch) | |
tree | 1e4a569dc09cbc45ec50a1a39b5cffb527f78921 | |
parent | da8fe0c5a8a3cfe86301329480bd1d2aa1740b93 (diff) | |
download | oslo-db-7b633804c5e8269a461e80fa1a27ddb7106e5405.tar.gz |
Capture DatabaseError for deadlock check4.7.1
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
(cherry picked from commit 3277ef33f2a1f6a892f0832e2907acef7b45dc2b)
-rw-r--r-- | oslo_db/sqlalchemy/exc_filters.py | 2 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_exc_filters.py | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py index ea7536d..3bd821f 100644 --- a/oslo_db/sqlalchemy/exc_filters.py +++ b/oslo_db/sqlalchemy/exc_filters.py @@ -58,7 +58,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.*") diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py index 5ec257e..da9cf2a 100644 --- a/oslo_db/tests/sqlalchemy/test_exc_filters.py +++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py @@ -645,7 +645,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): |