From: Kevin Benton Date: Fri, 4 Sep 2015 12:33:46 +0000 (-0700) Subject: Stop logging deadlock tracebacks X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=a93886278f1308ae78c65b4ad36ee7648cad2914;p=openstack-build%2Fneutron-build.git Stop logging deadlock tracebacks 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 --- diff --git a/neutron/db/api.py b/neutron/db/api.py index 53ef51b95..a77bcaec9 100644 --- a/neutron/db/api.py +++ b/neutron/db/api.py @@ -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(): diff --git a/neutron/db/quota/driver.py b/neutron/db/quota/driver.py index c9249950f..cc7a5425d 100644 --- a/neutron/db/quota/driver.py +++ b/neutron/db/quota/driver.py @@ -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. diff --git a/neutron/plugins/ml2/drivers/type_tunnel.py b/neutron/plugins/ml2/drivers/type_tunnel.py index fec72c84e..a8ac2fccf 100644 --- a/neutron/plugins/ml2/drivers/type_tunnel.py +++ b/neutron/plugins/ml2/drivers/type_tunnel.py @@ -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() diff --git a/neutron/plugins/ml2/plugin.py b/neutron/plugins/ml2/plugin.py index 45d48f51a..58110c5d5 100644 --- a/neutron/plugins/ml2/plugin.py +++ b/neutron/plugins/ml2/plugin.py @@ -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): diff --git a/neutron/quota/resource.py b/neutron/quota/resource.py index aa580d9c5..9c8b5ec2f 100644 --- a/neutron/quota/resource.py +++ b/neutron/quota/resource.py @@ -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)