Create Port Error - Conflict with persistent instance

Bug #1567844 reported by vks1
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Expired
Undecided
Unassigned

Bug Description

Using extended firewall plugin, which uses core_plugin (ML2 plugin) to create and delete port.

Steps:

1. Delete the router attached interface.
2. Delete the corresponding router port.
3. Create new port with same IP.

Suspect using same context consecutively to delete and create port, getting below exception. As, with new context didn't get the error.

Exception:

2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher [req-d240dbe4-6f75-489d-a709-6ff06bb8fa22 admin -] Exception during message handling: New instan
ce <IPAllocation at 0x7fc803f00f90> with identity key (<class 'neutron.db.models_v2.IPAllocation'>, (u'12.0.0.1', u'ebc4f10e-f109-4c80-9f4f-1b0979981318', u'f3c2535c-120e-43ab-a363-db35e49bcb68')) conflicts with persistent instance <IPAllocation at 0x7fc803e10210>
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher Traceback (most recent call last):
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 138, in _
dispatch_and_reply
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher incoming.message))
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 185, in _
dispatch
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher return self._do_dispatch(endpoint, method, ctxt, args)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 127, in _
do_dispatch
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher result = func(ctxt, **new_args)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/opt/stack/neutron-fwaas/neutron_fwaas/services/firewall/nfp_fw/nfp_fw_plugin.py", line
72, in get_router_interfaces_details
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher context.elevated(), {'port': new_port})
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1115, in create_port
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher result, mech_context = self._create_port_db(context, port)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1089, in _create_port_db
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher port_db = self.create_port_db(context, port)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 1256, in create_port_db
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher db_port['dns_assignment'] = dns_assignment
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 490, in __exit__
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher self.rollback()
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __ex
it__
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher compat.reraise(exc_type, exc_value, exc_tb)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 487, in __exit__
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher self.commit()
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 392, in commit
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher self._prepare_impl()
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher self.session.flush()
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2019, in flush
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher self._flush(objects)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2019, in flush
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher self._flush(objects)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2137, in _flush
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher transaction.rollback(_capture_exception=True)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher compat.reraise(exc_type, exc_value, exc_tb)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2101, in _flush
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher flush_context.execute()
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher rec.execute(self)
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher uow
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 149, in save_obj
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher base_mapper, states, uowtransaction
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 301, in _organize_states_for_save
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher state_str(existing)))
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher FlushError: New instance <IPAllocation at 0x7fc803f00f90> with identity key (<class 'neutron.db.models_v2.IPAllocation'>, (u'12.0.0.1', u'ebc4f10e-f109-4c80-9f4f-1b0979981318', u'f3c2535c-120e-43ab-a363-db35e49bcb68')) conflicts with persistent instance <IPAllocation at 0x7fc803e10210>
2016-04-08 13:22:28.061 27920 ERROR oslo_messaging.rpc.dispatcher
2016-04-08 13:22:28.064 27920 ERROR oslo_messaging._drivers.common [req-d240dbe4-6f75-489d-a709-6ff06bb8fa22 admin -] Returning exception New instance <IPAllocation at 0x7fc803f00f90> with identity key (<class 'neutron.db.models_v2.IPAllocation'>, (u'12.0.0.1', u'ebc4f10e-f109-4c80-9f4f-1b0979981318', u'f3c2535c-120e-43ab-a363-db35e49bcb68')) conflicts with persistent instance <IPAllocation at 0x7fc803e10210> to caller
2016-04-08 13:22:28.064 27920 ERROR oslo_messaging._drivers.common [req-d240dbe4-6f75-489d-a709-6ff06bb8fa22 admin -] ['Traceback (most recent call last):\n', ' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 138, in _dispatch_and_reply\n incoming.message))\n', ' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 185, in _dispatch\n return self._do_dispatch(endpoint, method, ctxt, args)\n', ' File "/usr/local/lib/python2.7/dist-packages/oslo_messaging/rpc/dispatcher.py", line 127, in _do_dispatch\n result = func(ctxt, **new_args)\n', ' File "/opt/stack/neutron-fwaas/neutron_fwaas/services/firewall/nfp_fw/nfp_fw_plugin.py", line 72, in get_router_interfaces_details\n context.elevated(), {\'port\': new_port})\n', ' File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1115, in create_port\n result, mech_context = self._create_port_db(context, port)\n', ' File "/opt/stack/neutron/neutron/plugins/ml2/plugin.py", line 1089, in _create_port_db\n port_db = self.create_port_db(context, port)\n', ' File "/opt/stack/neutron/neutron/db/db_base_plugin_v2.py", line 1256, in create_port_db\n db_port[\'dns_assignment\'] = dns_assignment\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 490, in __exit__\n self.rollback()\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__\n compat.reraise(exc_type, exc_value, exc_tb)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 487, in __exit__\n self.commit()\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 392, in commit\n self._prepare_impl()\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 372, in _prepare_impl\n self.session.flush()\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2019, in flush\n self._flush(objects)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2137, in _flush\n transaction.rollback(_capture_exception=True)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/util/langhelpers.py", line 60, in __exit__\n compat.reraise(exc_type, exc_value, exc_tb)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 2101, in _flush\n flush_context.execute()\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 373, in execute\n rec.execute(self)\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/unitofwork.py", line 532, in execute\n uow\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 149, in save_obj\n base_mapper, states, uowtransaction\n', ' File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/persistence.py", line 301, in _organize_states_for_save\n state_str(existing)))\n', "FlushError: New instance <IPAllocation at 0x7fc803f00f90> with identity key (<class 'neutron.db.models_v2.IPAllocation'>, (u'12.0.0.1', u'ebc4f10e-f109-4c80-9f4f-1b0979981318', u'f3c2535c-120e-43ab-a363-db35e49bcb68')) conflicts with persistent instance <IPAllocation at 0x7fc803e10210>\n"]

Revision history for this message
Gary Kotton (garyk) wrote :

On trunk I am unable to reproduce this issue. Can you please provide the exact steps that you took.

Changed in neutron:
status: New → Incomplete
Revision history for this message
vks1 (vikash-kumar) wrote :

I am extending Firewall Plugin.

Here is the excerpt from code.

1. Get ML2 plugin.

    core_plugin = manager.NeutronManager.get_plugin()

2. port = core_plugin.get_port(context, port_id)
     core_plugin.delete_port(context, port_id)

3. new_port_body = {'name': 'private', admin_state_up=True, tenant_id=<admin_tenant_id>, network_id=port['network_id']}

core_plugin.create_port(context, {'port': new_port_body})

  I can share code if not clear.

Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.