Sync router fails with db exception

Bug #1210877 reported by Maru Newby
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
neutron
Fix Released
Medium
ZhiQiang Fan

Bug Description

While investigating https://bugs.launchpad.net/neutron/+bug/1210664, salvatore-orlando discovered that a db exception was being raised during router syncing:

Traceback (most recent call last):
  File "/opt/stack/neutron/neutron/openstack/common/rpc/amqp.py", line 424, in _process_data
    **args)
  File "/opt/stack/neutron/neutron/common/rpc.py", line 44, in dispatch
    neutron_ctxt, version, method, namespace, **kwargs)
  File "/opt/stack/neutron/neutron/openstack/common/rpc/dispatcher.py", line 172, in dispatch
    result = getattr(proxyobj, method)(ctxt, **kwargs)
  File "/opt/stack/neutron/neutron/db/l3_rpc_base.py", line 47, in sync_routers
    plugin.auto_schedule_routers(context, host, router_ids)
  File "/opt/stack/neutron/neutron/db/agentschedulers_db.py", line 303, in auto_schedule_routers
    self, context, host, router_ids)
  File "/opt/stack/neutron/neutron/scheduler/l3_agent_scheduler.py", line 113, in auto_schedule_routers
    context.session.add(binding)
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 456, in __exit__
    self.commit()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 368, in commit
    self._prepare_impl()
  File "/usr/local/lib/python2.7/dist-packages/sqlalchemy/orm/session.py", line 347, in _prepare_impl
    self.session.flush()
  File "/opt/stack/neutron/neutron/openstack/common/db/sqlalchemy/session.py", line 542, in _wrap
    raise exception.DBError(e)
DBError: (IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (`ovs_neutron`.`routerl3agentbindings`, CONSTRAINT `routerl3agentbindings_ibfk_1` FOREIGN KEY (`router_id`) REFERENCES `routers` (`id`) ON DELETE CASCADE)') 'INSERT INTO routerl3agentbindings (id, router_id, l3_agent_id) VALUES (%s, %s, %s)' ('2df68c3d-f3c9-43d2-bf45-e2e57e84b054', 'c4502f1f-a093-4c7c-b161-929b6342509b', '85d6b60f-f3ff-4437-8f5a-af165087f3ea')

This can be reproduced by running the quantum smoke test in tempest (nosetests tempest/scenario/test_network_basic_ops.py). The smoke test passes - the exception only occurs at test cleanup. It may be that the router syncing code is working with stale state after router deletion.

Tags: l3-ipam-dhcp
tags: added: l3-ipam-dhcp
Sandhya Dasu (sadasu)
Changed in neutron:
assignee: nobody → Sandhya Dasu (sadasu)
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

I've raised this to High because if we disable auto-schema generation in Havana, the l3 agent scheduling - and possibly router synchronization - would be pretty much broken.

Changed in neutron:
milestone: none → havana-3
importance: Undecided → High
Revision history for this message
Salvatore Orlando (salvatore-orlando) wrote :

I haven't seen this in a while, scaling down to Incomplete to perform further checks.

Changed in neutron:
status: New → Incomplete
importance: High → Medium
Changed in neutron:
milestone: havana-3 → none
milestone: none → havana-rc1
Revision history for this message
Xiang Hui (xianghui) wrote :

This can be replicated by commenting "#router_id= "and setting "use_namespace=False", then restart neutron-l3-agent.
The router_id will be assigned the default value '', which mismatch DB format.

Changed in neutron:
status: Incomplete → Confirmed
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to neutron (master)

Fix proposed to branch: master
Review: https://review.openstack.org/47218

Changed in neutron:
assignee: Sandhya Dasu (sadasu) → ZhiQiang Fan (aji-zqfan)
status: Confirmed → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to neutron (master)

Reviewed: https://review.openstack.org/47218
Committed: http://github.com/openstack/neutron/commit/3e1116eb0f1d94530707cd6ef4b37f17e9a13918
Submitter: Jenkins
Branch: master

commit 3e1116eb0f1d94530707cd6ef4b37f17e9a13918
Author: ZhiQiang Fan <email address hidden>
Date: Thu Sep 19 01:53:44 2013 +0800

    Ensure router exists when auto_schedule_routers

    Currently, the auto_schedule_routers() accepts parameter router_ids,
    which may contain invalid router ids, since we've already filtered
    them via plugin.get_routers(), we can directly use that safe object.

    Closes-Bug: #1217998
    Closes-Bug: #1210877

    Change-Id: I6196f16cca65fee4e848173d0a0a10fde967195d

Changed in neutron:
status: In Progress → Fix Committed
Thierry Carrez (ttx)
Changed in neutron:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in neutron:
milestone: havana-rc1 → 2013.2
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.