From f26d0e09738da6c4faa9ddc08767779289931b42 Mon Sep 17 00:00:00 2001 From: Roman Podoliaka Date: Fri, 9 Dec 2016 15:44:42 +0200 Subject: exc_filters: fix deadlock detection for percona xtradb cluster percona xtradb cluster server produces an error like: (1213, u'WSREP detected deadlock/conflict and aborted the transaction. Try restarting the transaction') which is currently not detected properly and, thus, not retried. Closes-Bug: #1648818 Change-Id: Ic43cb0e0946506a4b7ce9f94ee9eba5e025ed3d5 (cherry picked from commit 7c8f0f48bfb941dc1147768493bbaf81bb437d58) --- oslo_db/sqlalchemy/exc_filters.py | 2 ++ oslo_db/tests/sqlalchemy/test_exc_filters.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py index b9b1d72..f189ac4 100644 --- a/oslo_db/sqlalchemy/exc_filters.py +++ b/oslo_db/sqlalchemy/exc_filters.py @@ -62,6 +62,8 @@ def filters(dbname, exception_type, regex): @filters("mysql", sqla_exc.DatabaseError, r"^.*\b1205\b.*Lock wait timeout exceeded.*") @filters("mysql", sqla_exc.InternalError, r"^.*\b1213\b.*Deadlock found.*") +@filters("mysql", sqla_exc.InternalError, + r"^.*\b1213\b.*detected deadlock/conflict.*") @filters("postgresql", sqla_exc.OperationalError, r"^.*deadlock detected.*") @filters("postgresql", sqla_exc.DBAPIError, r"^.*deadlock detected.*") @filters("ibm_db_sa", sqla_exc.DBAPIError, r"^.*SQL0911N.*") diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py index de9726a..fdb6618 100644 --- a/oslo_db/tests/sqlalchemy/test_exc_filters.py +++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py @@ -859,6 +859,14 @@ class TestDeadlock(TestsExceptionFilter): "transaction')" ) + def test_mysql_pymysql_wsrep_deadlock(self): + self._run_deadlock_detect_test( + "mysql", + "(1213, 'WSREP detected deadlock/conflict and aborted the " + "transaction. Try restarting the transaction')", + orig_exception_cls=self.InternalError + ) + def test_mysql_pymysql_galera_deadlock(self): self._run_deadlock_detect_test( "mysql", -- cgit v1.2.1