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
This commit is contained in:
parent
4d63a13681
commit
cb3f86dd78
@ -910,11 +910,11 @@ class NeutronDbPluginV2(neutron_plugin_base_v2.NeutronPluginBaseV2,
|
|||||||
objects.append(obj_creator(context, item))
|
objects.append(obj_creator(context, item))
|
||||||
context.session.commit()
|
context.session.commit()
|
||||||
except Exception:
|
except Exception:
|
||||||
|
context.session.rollback()
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
LOG.error(_("An exception occurred while creating "
|
LOG.error(_("An exception occurred while creating "
|
||||||
"the %(resource)s:%(item)s"),
|
"the %(resource)s:%(item)s"),
|
||||||
{'resource': resource, 'item': item})
|
{'resource': resource, 'item': item})
|
||||||
context.session.rollback()
|
|
||||||
return objects
|
return objects
|
||||||
|
|
||||||
def create_network_bulk(self, context, networks):
|
def create_network_bulk(self, context, networks):
|
||||||
|
Loading…
Reference in New Issue
Block a user