From f218929bc5126466b2a79b56d32e9cf042aa176d Mon Sep 17 00:00:00 2001 From: Brandon Logan Date: Tue, 8 Dec 2015 18:24:28 -0600 Subject: [PATCH] Force service provider relationships to load A race condition was exposed in the LBaaS V2 db layer that was caused by a hack to get around this issue. The real issue is that since the ProviderResourceAssociation is inserted independently, any models that were created before this insert will not have their relationship with the ProviderResourceAssocation loaded. Using the session.expire_all method will force the session to retrieve all new data and load this relationship for any resource that uses this relationship. Change-Id: I940b541f4ef9c489126cd2d215b1d857f0624de0 Closes-Bug: #1504465 --- neutron/db/servicetype_db.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/neutron/db/servicetype_db.py b/neutron/db/servicetype_db.py index 825f3cff2..61f2de56f 100644 --- a/neutron/db/servicetype_db.py +++ b/neutron/db/servicetype_db.py @@ -93,6 +93,14 @@ class ServiceTypeManager(object): assoc = ProviderResourceAssociation(provider_name=provider_name, resource_id=resource_id) context.session.add(assoc) + # NOTE(blogan): the ProviderResourceAssociation relationship will not + # be populated if a resource was created before this. The expire_all + # will force the session to go retrieve the new data when that + # resource will be read again. It has been suggested that we can + # crawl through everything in the mapper to find the resource with + # the ID that matches resource_id and expire that one, but we can + # just start with this. + context.session.expire_all() def del_resource_associations(self, context, resource_ids): if not resource_ids: -- 2.45.2