Skip to content

Commit

Permalink
add a retry on DBDeadlock to _set_allocations()
Browse files Browse the repository at this point in the history
A job failed with an uncaught DBDeadlock when attempting to run the
claim process in https://review.openstack.org/#/c/483566/. This is
likely due to the update_available_resource() method of the resource
tracker running and updating a resource provider's inventory (and thus
the resource provider record's generation field) at the exact same time
that the scheduler has already started a transaction that is attempting
to claim resources (set allocations) against that same resource
provider. It's a rare situation that is highlighted by the test runs
but we should handle it regardless.

Change-Id: I2c276dc0125b5b9f7a54a1cd431b1b2f5239e93a
  • Loading branch information
jaypipes committed Jul 26, 2017
1 parent 6e595b4 commit e001b05
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions nova/objects/resource_provider.py
Expand Up @@ -18,6 +18,7 @@

import os_traits
from oslo_concurrency import lockutils
from oslo_db import api as oslo_db_api
from oslo_db import exception as db_exc
from oslo_log import log as logging
from oslo_utils import versionutils
Expand Down Expand Up @@ -1791,6 +1792,7 @@ def _ensure_consumer_project_user(self, conn, consumer_id):
# if the consumer already exists.
pass

@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@db_api.api_context_manager.writer
def _set_allocations(self, context, allocs):
"""Write a set of allocations.
Expand Down

0 comments on commit e001b05

Please sign in to comment.