From 2a7cf9a97476ab1e56c5b3724b0d60cc29e7db1f Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Tue, 17 Oct 2017 18:35:04 +0900 Subject: [PATCH] create_security_group: Expunge an object selectively This expunge_all() can detach unrelated DB objects. Especially it can have wider effects with surrounding transactions, used by some of service plugins like networking-midonet L3 plugin. The problem was exposed by the recent OVO change [1] on networking-midonet gate jobs. [1] I5dcf9dc358c1122b2b22a6c4f40ae0b170e2003c Closes-Bug: #1724138 Change-Id: Ib2227e332c52d2f7225c41f57108c38641348183 --- neutron/db/securitygroups_db.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/neutron/db/securitygroups_db.py b/neutron/db/securitygroups_db.py index 4e4c60b1061..28bfb03b15d 100644 --- a/neutron/db/securitygroups_db.py +++ b/neutron/db/securitygroups_db.py @@ -121,7 +121,8 @@ class SecurityGroupDbMixin(ext_sg.SecurityGroupPluginBase): # of the SG. It would add SG object to the session. # Expunge it to ensure the following get_object doesn't # use the instance. - context.session.expunge_all() + context.session.expunge(model_query.get_by_id( + context, sg_models.SecurityGroup, sg.id)) sg = sg_obj.SecurityGroup.get_object(context, id=sg.id) secgroup_dict = self._make_security_group_dict(sg) kwargs['security_group'] = secgroup_dict