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
This commit is contained in:
melanie witt 2024-03-15 01:19:55 +00:00
parent 3a94baa0e2
commit 8e1f869910
2 changed files with 8 additions and 0 deletions

View File

@ -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):

View File

@ -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",