summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--oslo_db/api.py5
-rw-r--r--oslo_db/tests/test_api.py12
2 files changed, 12 insertions, 5 deletions
diff --git a/oslo_db/api.py b/oslo_db/api.py
index dcba2a3..ea1d41d 100644
--- a/oslo_db/api.py
+++ b/oslo_db/api.py
@@ -139,11 +139,6 @@ class wrap_db_retry(object):
with excutils.save_and_reraise_exception() as ectxt:
if remaining > 0:
ectxt.reraise = not self._is_exception_expected(e)
- if ectxt.reraise:
- # We got an unexpected exception so stop
- # retrying, log it and raise it up to the
- # caller.
- LOG.exception(_LE('DB error.'))
else:
LOG.exception(_LE('DB exceeded retry limit.'))
# if it's a RetryRequest, we need to unpack it
diff --git a/oslo_db/tests/test_api.py b/oslo_db/tests/test_api.py
index 56d5529..d3e9834 100644
--- a/oslo_db/tests/test_api.py
+++ b/oslo_db/tests/test_api.py
@@ -220,3 +220,15 @@ class DBRetryRequestCase(DBAPITestCase):
dbapi.api_class_call1()
self.assertFalse(mocked_wrap.called)
+
+ @mock.patch('oslo_db.api.LOG')
+ def test_retry_wrapper_non_db_error_not_logged(self, mock_log):
+ # Tests that if the retry wrapper hits a non-db error (raised from the
+ # wrapped function), then that exception is reraised but not logged.
+
+ @api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
+ def some_method():
+ raise AttributeError('test')
+
+ self.assertRaises(AttributeError, some_method)
+ self.assertFalse(mock_log.called)