Merge "Retry on DBDeadLock affecting worker updates"

This commit is contained in:
Zuul 2018-12-19 00:40:22 +00:00 committed by Gerrit Code Review
commit 5dfd180950
1 changed files with 4 additions and 0 deletions

View File

@ -1609,6 +1609,7 @@ def volume_attached(context, attachment_id, instance_uuid, host_name,
@handle_db_data_error
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
def volume_create(context, values):
values['volume_metadata'] = _metadata_refs(values.get('metadata'),
models.VolumeMetadata)
@ -6935,6 +6936,7 @@ def _worker_set_updated_at_field(values):
values['updated_at'] = updated_at
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
def worker_create(context, **values):
"""Create a worker entry from optional arguments."""
_worker_set_updated_at_field(values)
@ -6971,6 +6973,7 @@ def _orm_worker_update(worker, values):
setattr(worker, key, value)
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
def worker_update(context, id, filters=None, orm_worker=None, **values):
"""Update a worker with given values."""
filters = filters or {}
@ -6989,6 +6992,7 @@ def worker_update(context, id, filters=None, orm_worker=None, **values):
return result
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
def worker_claim_for_cleanup(context, claimer_id, orm_worker):
"""Claim a worker entry for cleanup."""
# We set updated_at value so we are sure we update the DB entry even if the