From 3a37c95075b3cfcf360afc4a1948c4b2989caafc Mon Sep 17 00:00:00 2001 From: Rodolfo Alonso Hernandez Date: Tue, 3 Sep 2024 10:31:24 +0000 Subject: [PATCH] Protect the "standardattr" retrieval from a concurrent deletion The method ``_extend_tags_dict`` can be called from a "list" operation. If one resource and its "standardattr" register is deleted concurrently, the "standard_attr" field retrieval will fail. The "list" operation is protected with a READER transaction context; however this is failing with the DB PostgreSQL backend. Closes-Bug: #2078787 Change-Id: I55142ce21cec8bd8e2d6b7b8b20c0147873699da (cherry picked from commit c7d07b7421034c2722fb0d0cfd2371e052928b97) --- neutron/services/tag/tag_plugin.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/neutron/services/tag/tag_plugin.py b/neutron/services/tag/tag_plugin.py index 23f3cb9ed1a..3c163b5c743 100644 --- a/neutron/services/tag/tag_plugin.py +++ b/neutron/services/tag/tag_plugin.py @@ -47,7 +47,17 @@ class TagPlugin(tagging.TagPluginBase): def _extend_tags_dict(response_data, db_data): if not directory.get_plugin(tagging.TAG_PLUGIN_TYPE): return - tags = [tag_db.tag for tag_db in db_data.standard_attr.tags] + try: + tags = [tag_db.tag for tag_db in db_data.standard_attr.tags] + except AttributeError: + # NOTE(ralonsoh): this method can be called from a "list" + # operation. If one resource and its "standardattr" register is + # deleted concurrently, the "standard_attr" field retrieval will + # fail. + # The "list" operation is protected with a READER transaction + # context; however this is failing with the DB PostgreSQL backend. + # https://bugs.launchpad.net/neutron/+bug/2078787 + tags = [] response_data['tags'] = tags @db_api.CONTEXT_READER