Bug 879918

Summary: [rhevm-upgrade] upgrade from 3.0.7 to SI24.4 fails: ERROR: insert or update on table "vm_device" violates foreign key constraint "fk_vm_device_vm _static"
Product: Red Hat Enterprise Virtualization Manager Reporter: Haim <hateya>
Component: ovirt-engine-setupAssignee: Eli Mesika <emesika>
Status: CLOSED CURRENTRELEASE QA Contact: Pavel Stehlik <pstehlik>
Severity: urgent Docs Contact:
Priority: urgent    
Version: 3.2.0CC: bazulay, dyasny, emesika, iheim, mgoldboi, Rhev-m-bugs, sgrinber, yeylon, ykaul, yzaslavs
Target Milestone: ---Keywords: TestBlocker
Target Release: 3.1.0   
Hardware: x86_64   
OS: Linux   
Whiteboard: integration infra
Fixed In Version: si24.5 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-12-13 15:43:56 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Haim 2012-11-25 12:41:03 UTC
Description of problem:

upgrade of QE production setup running 3.0.7 to latest SI24.4 (RC) is failing on the following:


2012-11-25 13:41:11::DEBUG::common_utils::341::root:: stderr = psql:upgrade/03_01_0440_vm_device_upgrade_data.sql:194: ERROR:  insert or update on table "vm_device" violates foreign key constraint "fk_vm_device_vm
_static"
DETAIL:  Key (vm_id)=(7cbdb1f6-e8dc-4c9b-9b60-60c1224428bf) is not present in table "vm_static".
CONTEXT:  SQL statement "insert INTO vm_device( device_id, vm_id, type, device, address, boot_order, spec_params, is_managed, is_plugged, is_readonly) select id, vmt_guid, 'interface', 'bridge', '', null, '', true
, true, false from vm_interface where vmt_guid IS NOT NULL"
PL/pgSQL function "__temp_vm_device_upgrade_data" line 21 at SQL statement

2012-11-25 13:41:11::DEBUG::common_utils::342::root:: retcode = 3
2012-11-25 13:41:11::ERROR::rhevm-upgrade::1264::root:: Traceback (most recent call last):
  File "/usr/bin/rhevm-upgrade", line 1250, in main
    runFunc([db.update], MSG_INFO_DB_UPDATE)
  File "/usr/bin/rhevm-upgrade", line 663, in runFunc
    func()
  File "/usr/bin/rhevm-upgrade", line 601, in update
    output, rc = utils.execCmd(cmdList=cmd, failOnError=True, msg=MSG_ERROR_UPDATE_DB)
  File "/usr/share/ovirt-engine/scripts/common_utils.py", line 345, in execCmd
    raise Exception(msg)
Exception: Error: Database update failed

data-base is attached - just run upgrade script on it.

Comment 8 Eli Mesika 2012-11-26 09:06:26 UTC
This bug is a result of missing FK between vmt_guid in vm_interface and
vm_guid in vm_static.
This cause junk interface left in vm_interface when a template that
has interfaces is removed.
Since in upgrade from 3.0 to 3.1 we added the vm_device table, there is
an attempt to insert those junk interfaces to vm_device that fails on
the FK constraint between vm_device and vm_static.

Comment 9 Eli Mesika 2012-11-26 09:08:29 UTC
http://gerrit.ovirt.org/#/c/9462/

Comment 12 Eli Mesika 2012-11-26 09:55:39 UTC
fixed in commit : cca1d99