Fix race condition on ml2 delete and update port methods
Synchronize access to ports table when deleting and updating a port. Otherwise concurrent update/delete request for the same port may cause neutron server to throw an exception and return '500 Internal server error' for such requests. Change-Id: I868002643147ce6baace5671cffb38b4f5e66729 Closes-Bug: #1266537
This commit is contained in:
parent
3f8bdd39c8
commit
03b9553fc2
@ -589,7 +589,10 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
session = context.session
|
session = context.session
|
||||||
changed_fixed_ips = 'fixed_ips' in port['port']
|
changed_fixed_ips = 'fixed_ips' in port['port']
|
||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
original_port = super(Ml2Plugin, self).get_port(context, id)
|
port_db = (session.query(models_v2.Port).
|
||||||
|
enable_eagerloads(False).
|
||||||
|
filter_by(id=id).with_lockmode('update').one())
|
||||||
|
original_port = self._make_port_dict(port_db)
|
||||||
updated_port = super(Ml2Plugin, self).update_port(context, id,
|
updated_port = super(Ml2Plugin, self).update_port(context, id,
|
||||||
port)
|
port)
|
||||||
if self.is_address_pairs_attribute_updated(original_port, port):
|
if self.is_address_pairs_attribute_updated(original_port, port):
|
||||||
@ -641,7 +644,11 @@ class Ml2Plugin(db_base_plugin_v2.NeutronDbPluginV2,
|
|||||||
with session.begin(subtransactions=True):
|
with session.begin(subtransactions=True):
|
||||||
if l3plugin:
|
if l3plugin:
|
||||||
l3plugin.disassociate_floatingips(context, id)
|
l3plugin.disassociate_floatingips(context, id)
|
||||||
port = self.get_port(context, id)
|
port_db = (session.query(models_v2.Port).
|
||||||
|
enable_eagerloads(False).
|
||||||
|
filter_by(id=id).with_lockmode('update').one())
|
||||||
|
port = self._make_port_dict(port_db)
|
||||||
|
|
||||||
network = self.get_network(context, port['network_id'])
|
network = self.get_network(context, port['network_id'])
|
||||||
mech_context = driver_context.PortContext(self, context, port,
|
mech_context = driver_context.PortContext(self, context, port,
|
||||||
network)
|
network)
|
||||||
|
Loading…
Reference in New Issue
Block a user