]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
Stop logging deadlock tracebacks
authorKevin Benton <blak111@gmail.com>
Fri, 4 Sep 2015 12:33:46 +0000 (05:33 -0700)
committerKevin Benton <blak111@gmail.com>
Fri, 4 Sep 2015 12:42:10 +0000 (05:42 -0700)
The oslo db retry decorator logs a traceback everytime a deadlock
is encountered even though it is being retried. With multiple workers
and a Galera cluster, deadlocks are common occurences due to our use
of with_lockmode update so we should not be polluting the logs.

This patch adjusts our usage of the retry decorator to catch deadlocks
with the exception checker which does not log them until the retries
are exhausted.

Change-Id: I433fbbad61070e20ebe934b9247e36fc190fa3e0

neutron/db/api.py
neutron/db/quota/driver.py
neutron/plugins/ml2/drivers/type_tunnel.py
neutron/plugins/ml2/plugin.py
neutron/quota/resource.py

index 53ef51b957b6532b4dd5f8777caae371c564deb4..a77bcaec9ebe5869735029ace98e6f4c4cb06199 100644 (file)
@@ -17,6 +17,7 @@ import contextlib
 
 from oslo_config import cfg
 from oslo_db import api as oslo_db_api
+from oslo_db import exception as db_exc
 from oslo_db.sqlalchemy import session
 from oslo_utils import uuidutils
 from sqlalchemy import exc
@@ -28,8 +29,11 @@ from neutron.db import common_db_mixin
 _FACADE = None
 
 MAX_RETRIES = 10
-retry_db_errors = oslo_db_api.wrap_db_retry(max_retries=MAX_RETRIES,
-                                            retry_on_deadlock=True)
+is_deadlock = lambda e: isinstance(e, db_exc.DBDeadlock)
+retry_db_errors = oslo_db_api.wrap_db_retry(
+    max_retries=MAX_RETRIES,
+    exception_checker=is_deadlock
+)
 
 
 def _create_facade_lazily():
index c9249950fce6de42701af736addaafeaf6901b54..cc7a5425ddf1cfee75c472ab1e83d46d59238068 100644 (file)
@@ -137,7 +137,7 @@ class DbQuotaDriver(object):
                                retry_interval=0.1,
                                inc_retry_interval=True,
                                retry_on_request=True,
-                               retry_on_deadlock=True)
+                               exception_checker=db_api.is_deadlock)
     def make_reservation(self, context, tenant_id, resources, deltas, plugin):
         # Lock current reservation table
         # NOTE(salv-orlando): This routine uses DB write locks.
index fec72c84ea965dee6f5e33bfdc572b4ccf93f8e3..a8ac2fccf9029c39200a124e5a6e0c85345807dd 100644 (file)
@@ -124,7 +124,8 @@ class TunnelTypeDriver(helpers.SegmentTypeDriver):
                  {'type': self.get_type(), 'range': current_range})
 
     @oslo_db_api.wrap_db_retry(
-        max_retries=db_api.MAX_RETRIES, retry_on_deadlock=True)
+        max_retries=db_api.MAX_RETRIES,
+        exception_checker=db_api.is_deadlock)
     def sync_allocations(self):
         # determine current configured allocatable tunnel ids
         tunnel_ids = set()
index 45d48f51a561cfb01b1ffc7555b7783f6570d3ab..58110c5d5047b5cd9cb5b61af320e2b44ac5a416 100644 (file)
@@ -1443,9 +1443,9 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
         return self._bind_port_if_needed(port_context)
 
     @oslo_db_api.wrap_db_retry(
-        max_retries=db_api.MAX_RETRIES,
-        retry_on_deadlock=True, retry_on_request=True,
-        exception_checker=lambda e: isinstance(e, sa_exc.StaleDataError)
+        max_retries=db_api.MAX_RETRIES, retry_on_request=True,
+        exception_checker=lambda e: isinstance(e, (sa_exc.StaleDataError,
+                                                   os_db_exception.DBDeadlock))
     )
     def update_port_status(self, context, port_id, status, host=None,
                            network=None):
index aa580d9c55470e66dffc6710d5ecf36c70c74705..9c8b5ec2fa416d3550b5058a4af2588203c268cb 100644 (file)
@@ -211,9 +211,9 @@ class TrackedResource(BaseResource):
     # ensure that an UPDATE statement is emitted rather than an INSERT one
     @oslo_db_api.wrap_db_retry(
         max_retries=db_api.MAX_RETRIES,
-        retry_on_deadlock=True,
         exception_checker=lambda exc:
-        isinstance(exc, oslo_db_exception.DBDuplicateEntry))
+        isinstance(exc, (oslo_db_exception.DBDuplicateEntry,
+                         oslo_db_exception.DBDeadlock)))
     def _set_quota_usage(self, context, tenant_id, in_use):
         return quota_api.set_quota_usage(
             context, self.name, tenant_id, in_use=in_use)