From b64e5a35e1067976de3c92372476582b4d99a3ac Mon Sep 17 00:00:00 2001 From: Kiran Pawar Date: Tue, 15 Oct 2024 10:01:21 +0000 Subject: [PATCH] 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 Closes-bug: #2084529 Change-Id: Iac0bee438365ab0902859df74647f1502c619270 --- manila/db/sqlalchemy/api.py | 21 +++++++++++++++++++ ...ry-on-update-methods-538f3a295a110f3f.yaml | 6 ++++++ 2 files changed, 27 insertions(+) create mode 100644 releasenotes/notes/bug-2084529-add-db_retry-on-update-methods-538f3a295a110f3f.yaml diff --git a/manila/db/sqlalchemy/api.py b/manila/db/sqlalchemy/api.py index cc5f76a059..b735f270aa 100644 --- a/manila/db/sqlalchemy/api.py +++ b/manila/db/sqlalchemy/api.py @@ -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.""" diff --git a/releasenotes/notes/bug-2084529-add-db_retry-on-update-methods-538f3a295a110f3f.yaml b/releasenotes/notes/bug-2084529-add-db_retry-on-update-methods-538f3a295a110f3f.yaml new file mode 100644 index 0000000000..ebb3a5ce44 --- /dev/null +++ b/releasenotes/notes/bug-2084529-add-db_retry-on-update-methods-538f3a295a110f3f.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + Added db_retry on deadlock for various database update methods. + Please check `launchpad bug 2084529 + `_ for more details.