From: armando-migliaccio Date: Thu, 13 Feb 2014 19:36:34 +0000 (-0800) Subject: Ensure that session is rolled back on bulk creates X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=cb3f86dd781587eaa9fca6cc4a2f98de93526db7;p=openstack-build%2Fneutron-build.git Ensure that session is rolled back on bulk creates During bulk creates, the session is began explicitely; ensure that it gets rolled back before re-raising in order to avoid triggering InvalidRequestError exceptions when the session is reused. Partial-bug: 1244757 Change-Id: I797faeec2ca5374620db905599ab6e6f04fdcabd --- diff --git a/neutron/db/db_base_plugin_v2.py b/neutron/db/db_base_plugin_v2.py index f96edf9b0..d33310407 100644 --- a/neutron/db/db_base_plugin_v2.py +++ b/neutron/db/db_base_plugin_v2.py @@ -910,11 +910,11 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2, objects.append(obj_creator(context, item)) context.session.commit() except Exception: + context.session.rollback() with excutils.save_and_reraise_exception(): LOG.error(_("An exception occurred while creating " "the %(resource)s:%(item)s"), {'resource': resource, 'item': item}) - context.session.rollback() return objects def create_network_bulk(self, context, networks):