decorate all missing *_update methods with db_retry on deadlock

Share instance records and their relations were missing db_retry and
so added the db_retry decorator.

Co-Authored-By: Maurice Escher <maurice.escher@sap.com>
Closes-bug: #2084529
Change-Id: Iac0bee438365ab0902859df74647f1502c619270
(cherry picked from commit b64e5a35e1)
This commit is contained in:
Kiran Pawar 2024-10-15 10:01:21 +00:00
parent a1706e52a1
commit 052e324e26
2 changed files with 27 additions and 0 deletions

View File

@ -513,6 +513,7 @@ QUOTA_SYNC_FUNCTIONS = {
###################
@require_admin_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_resources_host_update(context, current_host, new_host):
"""Updates the 'host' attribute of resources"""
@ -1654,6 +1655,7 @@ def _share_instance_create(context, share_id, values):
@require_context
@require_availability_zone_exists(strict=False)
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_instance_update(context, share_instance_id, values,
with_share_data=False):
@ -1674,6 +1676,7 @@ def _share_instance_update(context, share_instance_id, values):
return share_instance_ref
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_and_snapshot_instances_status_update(
context, values, share_instance_ids=None, snapshot_instance_ids=None,
@ -1725,6 +1728,7 @@ def share_and_snapshot_instances_status_update(
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_instance_status_update(context, share_instance_ids, values):
return _share_instance_status_update(context, share_instance_ids, values)
@ -2340,6 +2344,7 @@ def _share_data_get_for_project(
@require_context
@require_availability_zone_exists(strict=False)
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_update(context, share_id, update_values):
return _share_update(context, share_id, update_values)
@ -2902,6 +2907,7 @@ def _share_access_metadata_get_query(context, access_id):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_access_metadata_update(context, access_id, metadata):
# Now update all existing items with new values, or create new meta
@ -3298,6 +3304,7 @@ def _share_snapshot_instance_create(context, snapshot_id, values):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_snapshot_instance_update(context, instance_id, values):
instance_ref = _share_snapshot_instance_get(context, instance_id)
@ -3735,6 +3742,7 @@ def _share_snapshot_update(context, snapshot_id, values):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_snapshot_instances_status_update(
context, snapshot_instance_ids, values,
@ -4003,6 +4011,7 @@ def _share_snapshot_access_get_all_for_snapshot_instance(
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_snapshot_instance_access_update(
context, access_id, instance_id, updates
@ -4850,6 +4859,7 @@ def share_network_delete(context, id):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_network_update(context, id, values):
network_ref = _share_network_get(context, id)
@ -4993,6 +5003,7 @@ def share_network_remove_security_service(context, id, security_service_id):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_network_update_security_service(
context, id, current_security_service_id, new_security_service_id,
@ -5395,6 +5406,7 @@ def share_server_delete(context, id):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_server_update(context, id, values):
server_ref = _share_server_get(context, id)
@ -5653,6 +5665,7 @@ def _share_server_backend_details_delete(context, share_server_id):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_servers_update(context, share_server_ids, values):
result = model_query(
@ -5696,6 +5709,7 @@ def driver_private_data_get(context, entity_id, key=None, default=None):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def driver_private_data_update(
context, entity_id, details, delete_existing=False,
@ -5820,6 +5834,7 @@ def network_allocations_get_for_share_server(
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def network_allocation_update(context, id, values, read_deleted=None):
alloc_ref = _network_allocation_get(context, id, read_deleted=read_deleted)
@ -6495,6 +6510,7 @@ def share_group_create(context, values):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_group_update(context, share_group_id, values):
share_group_ref = _share_group_get(
@ -6768,6 +6784,7 @@ def share_group_snapshot_create(context, values):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_group_snapshot_update(context, share_group_snapshot_id, values):
share_group_ref = _share_group_snapshot_get(
@ -6841,6 +6858,7 @@ def share_group_snapshot_member_create(context, values):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def share_group_snapshot_member_update(context, member_id, values):
_change_size_to_instance_size(values)
@ -7339,6 +7357,7 @@ def backend_info_create(context, host, value):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def backend_info_update(context, host, value=None, delete_existing=False):
"""Remove backend info for host name."""
@ -7400,6 +7419,7 @@ def async_operation_data_get(context, entity_id, key=None, default=None):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def async_operation_data_update(
context, entity_id, details, delete_existing=False,
@ -7599,6 +7619,7 @@ def resource_lock_create(context, kwargs):
@require_context
@oslo_db_api.wrap_db_retry(max_retries=5, retry_on_deadlock=True)
@context_manager.writer
def resource_lock_update(context, lock_id, kwargs):
"""Update a resource lock."""

View File

@ -0,0 +1,6 @@
---
fixes:
- |
Added db_retry on deadlock for various database update methods.
Please check `launchpad bug 2084529
<https://bugs.launchpad.net/manila/+bug/2084529>`_ for more details.