Bug 1353219

Summary: Fail to upgrade db if storage domain with memory was removed
Product: [oVirt] ovirt-engine Reporter: Arik <ahadas>
Component: BLL.VirtAssignee: Arik <ahadas>
Status: CLOSED CURRENTRELEASE QA Contact: sefi litmanovich <slitmano>
Severity: high Docs Contact:
Priority: urgent    
Version: 4.0.2CC: bugs, nicolas, Sustugriel, ylavi
Target Milestone: ovirt-4.0.1Keywords: ZStream
Target Release: 4.0.1.1Flags: rule-engine: ovirt-4.0.z+
rule-engine: blocker+
ylavi: testing_plan_complete?
ylavi: planning_ack+
ahadas: devel_ack+
mavital: testing_ack+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Upgrade to 4.0 could fail if there were snapshot whose memory is inaccessible. That is, memory volumes that have been manually removed from the storage domain or that reside on storage domain that were removed from the data center. This fix prevents the failure by removing references to such memory volumes during the upgrade.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-08-04 13:30:37 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Virt RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Arik 2016-07-06 14:45:03 UTC
Description of problem:
If there is a snapshot with memory that exists in the system such that the memory resides in a storage domain that was removed from the system later on (meaning it doesn't exists in the database anymore), one of the upgrade scripts fails.

Version-Release number of selected component (if applicable):


How reproducible:
100%

Steps to Reproduce:
1. Create a snapshot with memory in 3.6
2. Remove the storage domain that the memory resides in
3. Upgrade to 4.0

Actual results:
Failure:
 insert or update on table "image_storage_domain_map" violates foreign
 key constraint
 "fk_image_storage_domain_map_storage_domain_static"
 DETAIL:  Key (storage_domain_id)=(006552b0-cae3-4ccb-9baa-ee8c3b8e42cf)
 is not present in table "storage_domain_static".
 FATAL: Cannot execute sql command:
 --file=/usr/share/ovirt engine/dbscripts/upgrade/04_00_0140_convert_memory_snapshots_to_disks.sql

Expected results:
Upgrade should succeed

Additional info:
Setting priority to high as there is a workaround that was confirmed to work:
use the following query to identify the exact problematic snapshots and remove them before upgrading:
select vm_name, snapshots.description as snapshot_name, snapshot_id from snapshots join vm_static on vm_id=vm_guid where CAST(split_part(memory_volume, ',', 1) AS UUID) not in (select id from storage_domain_static);

Comment 1 sefi litmanovich 2016-07-24 14:14:57 UTC
Verified with rhevm-3.6.8.1-0.1.el6 upgrading to rhevm-4.0.2-0.1.rc.el7ev.noarch.

Steps:
1. On the 3.6 env, create a vm with disk.
2. Start the vm.
3. Create live snapshot with memory.
4. stop vm.
5. Add another SD to the cluster.
6. Move the vm's disk to the new SD.
7. Detach and remove (no format) the original SD from the engine.
8. Backup the engine with engine-backup tool.
9. Re provision the server and install rhel 7.2 with latest rhevm-4.0 repos.
10.Install rhevm-setup.
11. restore engine withe engine-backup tool.
12. Install engine with engine-setup.

setup succeeds with no errors.

Comment 2 Allon Mureinik 2016-07-25 12:18:20 UTC
*** Bug 1350220 has been marked as a duplicate of this bug. ***