diff options
author | Jenkins <jenkins@review.openstack.org> | 2015-08-04 04:04:48 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2015-08-04 04:04:48 +0000 |
commit | 2e76000e6955d05bd795fd1ebbe7ac74cf098de0 (patch) | |
tree | ffbd70bffd7428b769ca8b2160b8022834c19f5e /oslo_db | |
parent | 7b671d3165c2e80fb4b6120ba0c15b9b0fb27a04 (diff) | |
parent | 45079050f1d54c3be15ce128487f79c9490be77c (diff) | |
download | oslo-db-2e76000e6955d05bd795fd1ebbe7ac74cf098de0.tar.gz |
Merge "Added catching of errors 1047 (Galera) for MySQL oslo db reconnect"
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", |