boot-from-volume broken by foreign key constraints

Bug #1019334 reported by Eoghan Glynn
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Compute (nova)
Fix Released
High
Eoghan Glynn

Bug Description

Recently we've had a foreign key constraint added for the block_device_mapping table[1], introduced in this commit[2].

The problem is that it causes boot-from-volume to break[3], as the current code-path[4] populates the block_device_mapping
*before* the entry in the instances table entry has been created.

[1] mysql> show create table block_device_mapping \G
...
Create Table: CREATE TABLE `block_device_mapping` (
...
  CONSTRAINT `block_device_mapping_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`)
...

[2] https://github.com/openstack/nova/commit/25c50ca4b3ed8523b7d1c522ad5d05481fce7300#L4R34

[3] File "/opt/stack/nova/nova/compute/api.py", line 579, in _update_block_device_mapping
...
     raise DBError(e)
 DBError: (IntegrityError) (1452, 'Cannot add or update a child row: a foreign key constraint fails (`nova`.`block_device_mapping`, CONSTRAINT `block_device_mapping_instance_uuid_fkey` FOREIGN KEY (`instance_uuid`) REFERENCES `instances` (`uuid`))') 'INSERT INTO block_device_mapping ...

[4] https://github.com/openstack/nova/blob/master/nova/compute/api.py#L665

Eoghan Glynn (eglynn)
Changed in nova:
assignee: nobody → Eoghan Glynn (eglynn)
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to nova (master)

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

Changed in nova:
status: New → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to nova (master)

Reviewed: https://review.openstack.org/9177
Committed: http://github.com/openstack/nova/commit/ea711b229789d9db54b7e10fe4c67ee1bf1db8c6
Submitter: Jenkins
Branch: master

commit ea711b229789d9db54b7e10fe4c67ee1bf1db8c6
Author: Eoghan Glynn <email address hidden>
Date: Fri Jun 29 17:30:52 2012 +0000

    Create instance in DB before block device mapping

    Fixes lp 1019334

    A recently added foreign key constraint on the the block_device_mapping
    table causes boot-from-volume to fail, as the bdm is populated before the
    instance DB entry is created.

    This fix simply transposes the ordering to avoid breaking the constraint.

    Change-Id: Ic62ea3ba000a2cdf58d2bd5bb17dde2b8cf340e4

Changed in nova:
status: In Progress → Fix Committed
Brian Waldon (bcwaldon)
Changed in nova:
milestone: none → folsom-2
importance: Undecided → High
Thierry Carrez (ttx)
Changed in nova:
status: Fix Committed → Fix Released
Thierry Carrez (ttx)
Changed in nova:
milestone: folsom-2 → 2012.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.