From 8e1f869910e2fee3d567565b28b9cd520b07bacf Mon Sep 17 00:00:00 2001 From: melanie witt Date: Fri, 15 Mar 2024 01:19:55 +0000 Subject: [PATCH] exc_filters: Handle OperationalError for MariaDB/Galera Currently InternalError is being handled for detecting MariaDB/Galera deadlocks but recently we have seen a variant that raises OperationalError instead. Because it's not being detected, usage of the @retry_on_deadlock decorator is not performing retries in those cases. This adds handling of OperationalError for detecting this deadlock. Closes-Bug: #2057987 Change-Id: I6ff3667b35ea38a2d3c258f810a55eda9abe465e --- oslo_db/sqlalchemy/exc_filters.py | 2 ++ oslo_db/tests/sqlalchemy/test_exc_filters.py | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py index 83f17f1c..0aa9772c 100644 --- a/oslo_db/sqlalchemy/exc_filters.py +++ b/oslo_db/sqlalchemy/exc_filters.py @@ -65,6 +65,8 @@ def filters(dbname, exception_type, regex): r"^.*\b1213\b.*detected deadlock/conflict.*") @filters("mysql", sqla_exc.InternalError, r"^.*\b1213\b.*Deadlock: wsrep aborted.*") +@filters("mysql", sqla_exc.OperationalError, + r"^.*\b1213\b.*Deadlock: wsrep aborted.*") @filters("postgresql", sqla_exc.OperationalError, r"^.*deadlock detected.*") @filters("postgresql", sqla_exc.DBAPIError, r"^.*deadlock detected.*") def _deadlock_error(operational_error, match, engine_name, is_disconnect): diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py index 816ef7e7..76cf5704 100644 --- a/oslo_db/tests/sqlalchemy/test_exc_filters.py +++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py @@ -1006,6 +1006,12 @@ class TestDeadlock(TestsExceptionFilter): orig_exception_cls=self.InternalError ) + self._run_deadlock_detect_test( + "mysql", + "(1213, 'Deadlock: wsrep aborted transaction')", + orig_exception_cls=self.OperationalError + ) + def test_mysql_pymysql_galera_deadlock(self): self._run_deadlock_detect_test( "mysql",