diff options
author | Davanum Srinivas <davanum@gmail.com> | 2015-07-14 14:32:25 -0400 |
---|---|---|
committer | Davanum Srinivas <davanum@gmail.com> | 2015-07-14 14:32:29 -0400 |
commit | 45079050f1d54c3be15ce128487f79c9490be77c (patch) | |
tree | 10da34da4ff7c9508ca6040be1bed659b544564d /oslo_db | |
parent | 5554801ee6b76b14ed5dbbbc70a4b62e823b3deb (diff) | |
download | oslo-db-45079050f1d54c3be15ce128487f79c9490be77c.tar.gz |
Added catching of errors 1047 (Galera) for MySQL oslo db reconnect
Any service using oslo db reconnect feature should catch 1047 mysqldb error
which happens after galera cluster is in non-primary state. If we don't do
this, it can lead cluster being non-functional even after galera
functioning is restored.
Closes-Bug: #1312212
Change-Id: I4fa98c1dd49b7d6ed4305bd938e29b20ec7e31fb
Diffstat (limited to 'oslo_db')
-rw-r--r-- | oslo_db/sqlalchemy/exc_filters.py | 2 | ||||
-rw-r--r-- | oslo_db/tests/sqlalchemy/test_exc_filters.py | 18 |
2 files changed, 19 insertions, 1 deletions
diff --git a/oslo_db/sqlalchemy/exc_filters.py b/oslo_db/sqlalchemy/exc_filters.py index af8d992..57f8704 100644 --- a/oslo_db/sqlalchemy/exc_filters.py +++ b/oslo_db/sqlalchemy/exc_filters.py @@ -305,7 +305,7 @@ def _raise_operational_errors_directly_filter(operational_error, raise operational_error -@filters("mysql", sqla_exc.OperationalError, r".*\(.*(?:2002|2003|2006|2013)") +@filters("mysql", sqla_exc.OperationalError, r".*\(.*(?:2002|2003|2006|2013|1047)") # noqa @filters("postgresql", sqla_exc.OperationalError, r".*could not connect to server") # noqa @filters("ibm_db_sa", sqla_exc.OperationalError, r".*(?:30081)") def _is_db_connection_error(operational_error, match, engine_name, diff --git a/oslo_db/tests/sqlalchemy/test_exc_filters.py b/oslo_db/tests/sqlalchemy/test_exc_filters.py index 5e93dd4..dc1cd20 100644 --- a/oslo_db/tests/sqlalchemy/test_exc_filters.py +++ b/oslo_db/tests/sqlalchemy/test_exc_filters.py @@ -859,6 +859,24 @@ class TestDBDisconnected(TestsExceptionFilter): is_disconnect=False ) + def test_mysql_galera_non_primary_disconnected(self): + self._test_ping_listener_disconnected( + "mysql", + self.OperationalError('(1047, \'Unknown command\') ' + '\'SELECT DATABASE()\' ()') + ) + + def test_mysql_galera_non_primary_disconnected_regex_only(self): + # intentionally set the is_disconnect flag to False + # in the "sqlalchemy" layer to make sure the regexp + # on _is_db_connection_error is catching + self._test_ping_listener_disconnected( + "mysql", + self.OperationalError('(1047, \'Unknown command\') ' + '\'SELECT DATABASE()\' ()'), + is_disconnect=False + ) + def test_db2_ping_listener_disconnected(self): self._test_ping_listener_disconnected( "ibm_db_sa", |