From 1d545d3f195ae1fb98e4b7a572c1d4a50b7ea4a0 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 (cherry picked from commit b64e5a35e1067976de3c92372476582b4d99a3ac) (cherry picked from commit 052e324e26b6ebdc4b8e011df9f41b43f1cea09b) --- 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 a1d602085d..04b552763f 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""" @@ -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.""" 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.