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)
(cherry picked from commit 052e324e26)
This commit is contained in:
Kiran Pawar 2024-10-15 10:01:21 +00:00
parent a1030e8e5f
commit 1d545d3f19
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"""
@ -1652,6 +1653,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):
@ -1672,6 +1674,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,
@ -1723,6 +1726,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)
@ -2338,6 +2342,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)
@ -2900,6 +2905,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
@ -3279,6 +3285,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)
@ -3716,6 +3723,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,
@ -3984,6 +3992,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
@ -4804,6 +4813,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)
@ -4947,6 +4957,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,
@ -5349,6 +5360,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)
@ -5596,6 +5608,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(
@ -5639,6 +5652,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,
@ -5763,6 +5777,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)
@ -6438,6 +6453,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(
@ -6711,6 +6727,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(
@ -6784,6 +6801,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)
@ -7282,6 +7300,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."""
@ -7343,6 +7362,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,
@ -7542,6 +7562,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.