Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.

Bug 1454823

Summary: Restore snapshots table constraints to base_disks
Product: [oVirt] ovirt-engine Reporter: Fred Rolland <frolland>
Component: BLL.StorageAssignee: Eyal Shenitzky <eshenitz>
Status: CLOSED CURRENTRELEASE QA Contact: Kevin Alon Goldblatt <kgoldbla>
Severity: low Docs Contact:
Priority: unspecified    
Version: 4.2.0CC: amureini, bugs, eshenitz, ratamir, tnisan
Target Milestone: ovirt-4.2.0Flags: rule-engine: ovirt-4.2+
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2017-12-20 11:25:32 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Storage RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Fred Rolland 2017-05-23 14:05:15 UTC
As part of solving #1427104, the constraints between snapshots and base_disks regarding the memory volumes were removed.
This was needed to solve a transaction deadlock in RestoreAllSnapshotsCommand.

In newer version of Postgres, the locking mechanism will allow this flow to succeed.

The constraints to be restored.

SELECT fn_db_create_constraint('snapshots', 'fk_snapshots_metadata_disk_id', 'FOREIGN KEY (memory_metadata_disk_id) REFERENCES base_disks(disk_id) ON DELETE SET NULL');
SELECT fn_db_create_constraint('snapshots', 'fk_snapshots_dump_disk_id', 'FOREIGN KEY (memory_dump_disk_id) REFERENCES base_disks(disk_id) ON DELETE SET NULL');

Comment 1 Allon Mureinik 2017-09-19 12:34:00 UTC
Tal, just to confirm - this is still relevant after your recent work on disk content types, right?

Comment 2 Tal Nisan 2017-09-25 11:39:04 UTC
(In reply to Allon Mureinik from comment #1)
> Tal, just to confirm - this is still relevant after your recent work on disk
> content types, right?

Indeed, it is not relevant for that change, we should still go on with restoring the contraints

Comment 5 Kevin Alon Goldblatt 2017-12-11 10:07:45 UTC
Tested with the following code:
--------------------------------
ovirt-engine-4.2.0-0.6.el7.noarch
vdsm-4.20.9-1.el7ev.x86_64


Tested with following scenario:
--------------------------------
Run the following on the engine:

psql -U postgres engine -c '\d snapshots'
                          Table "public.snapshots"
         Column          |           Type           |       Modifiers        
-------------------------+--------------------------+------------------------
 snapshot_id             | uuid                     | not null
 vm_id                   | uuid                     | not null
 snapshot_type           | character varying(32)    | not null
 status                  | character varying(32)    | not null
 description             | character varying(4000)  | 
 creation_date           | timestamp with time zone | not null
 app_list                | text                     | 
 vm_configuration        | text                     | 
 _create_date            | timestamp with time zone | default now()
 _update_date            | timestamp with time zone | 
 memory_volume           | character varying(255)   | 
 memory_metadata_disk_id | uuid                     | 
 memory_dump_disk_id     | uuid                     | 
 vm_configuration_broken | boolean                  | not null default false
Indexes:
    "pk_snapshots" PRIMARY KEY, btree (snapshot_id)
    "idx_snapshots_memory_dump_disk_id" btree (memory_dump_disk_id)
    "idx_snapshots_memory_metadata_disk_id" btree (memory_metadata_disk_id)
    "idx_snapshots_snapshot_type" btree (snapshot_type)
    "idx_snapshots_vm_id" btree (vm_id)
Foreign-key constraints:
    "fk_snapshot_vm" FOREIGN KEY (vm_id) REFERENCES vm_static(vm_guid)
    "fk_snapshots_dump_disk_id" FOREIGN KEY (memory_dump_disk_id) REFERENCES base_disks(disk_id) ON DELETE SET NULL
    "fk_snapshots_metadata_disk_id" FOREIGN KEY (memory_metadata_disk_id) REFERENCES base_disks(disk_id) ON DELETE SET NULL
Referenced by:
    TABLE "vm_device" CONSTRAINT "vm_device_snapshot_id_fkey" FOREIGN KEY (snapshot_id) REFERENCES snapshots(snapshot_id) ON DELETE CASCADE


Moving to VERIFIED

Comment 6 Sandro Bonazzola 2017-12-20 11:25:32 UTC
This bugzilla is included in oVirt 4.2.0 release, published on Dec 20th 2017.

Since the problem described in this bug report should be
resolved in oVirt 4.2.0 release, published on Dec 20th 2017, it has been closed with a resolution of CURRENT RELEASE.

If the solution does not work for you, please open a new bug report.