From 9a0907dbb9eaf1dcf7f1ccfc22b0e6e4f775b046 Mon Sep 17 00:00:00 2001 From: YAMAMOTO Takashi Date: Mon, 3 Apr 2017 19:31:32 +0900 Subject: [PATCH] Flush objects by ourselves before processing before_commit event During commit processing, sqla automatically flushes objects. However, it does so after dispatching the before_commit event, while Neutron expects it happens before the event. This counter-intuitive behaviour might or might not be considered a bug in sqla. Anyway, it's better to be safe in our side. Closes-Bug: #1678726 Change-Id: Iceaf178be2885b0299d6d281983e9f7f8ae6def0 --- neutron/db/api.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/neutron/db/api.py b/neutron/db/api.py index 901038e9cd9..1ed194e5dbb 100644 --- a/neutron/db/api.py +++ b/neutron/db/api.py @@ -278,7 +278,10 @@ def load_one_to_manys(session): # have eliminated all places where related objects are constructed # using a key rather than a relationship. - add_to_rel_load_list(session) # capture any new objects + # capture any new objects + if session.new: + session.flush() + if session.transaction.nested: # wait until final commit return