From 2269848495d66ebaceb7c643888d715b9117390c Mon Sep 17 00:00:00 2001 From: Roman Podoliaka Date: Wed, 19 Nov 2014 18:48:24 +0200 Subject: Handle Galera deadlock on SELECT FOR UPDATE Using nova-api in the wild shows that we've got an additional exception, that must be treated like a deadlock, so that we can handle this error properly and retry the transaction. Closes-Bug: #1394298 Change-Id: If75f2b5984979fe55ad04ccec8713989307c56ae --- oslo/db/sqlalchemy/exc_filters.py | 2 ++ tests/sqlalchemy/test_exc_filters.py | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/oslo/db/sqlalchemy/exc_filters.py b/oslo/db/sqlalchemy/exc_filters.py index b3da401..ff6118e 100644 --- a/oslo/db/sqlalchemy/exc_filters.py +++ b/oslo/db/sqlalchemy/exc_filters.py @@ -58,6 +58,8 @@ 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, + 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.*") @filters("postgresql", sqla_exc.DBAPIError, r"^.*deadlock detected.*") diff --git a/tests/sqlalchemy/test_exc_filters.py b/tests/sqlalchemy/test_exc_filters.py index cb3d7ef..34dd991 100644 --- a/tests/sqlalchemy/test_exc_filters.py +++ b/tests/sqlalchemy/test_exc_filters.py @@ -491,6 +491,13 @@ class TestDeadlock(TestsExceptionFilter): "transaction')" ) + def test_mysql_mysqldb_galera_deadlock(self): + self._run_deadlock_detect_test( + "mysql", + "(1205, 'Lock wait timeout exceeded; " + "try restarting transaction')" + ) + def test_mysql_mysqlconnector_deadlock(self): self._run_deadlock_detect_test( "mysql", -- cgit v1.2.1