Bug 1013341

Summary: DB upgrade from 3.2 to 3.3 fails
Product: Red Hat Enterprise Virtualization Manager Reporter: Eli Mesika <emesika>
Component: ovirt-engineAssignee: Moti Asayag <masayag>
Status: CLOSED CURRENTRELEASE QA Contact: yeylon <yeylon>
Severity: high Docs Contact:
Priority: urgent    
Version: 3.3.0CC: acathrow, eedri, iheim, knesenko, lpeer, rhev-integ, Rhev-m-bugs, scohen, srevivo, yeylon
Target Milestone: ---Keywords: AutomationBlocker, Regression
Target Release: 3.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard: network
Fixed In Version: is17 Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: Network RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Bug Depends On:    
Bug Blocks: 1019461    
Attachments:
Description Flags
3.2 database
none
port mirroring is enabled (VM_Network_35_pm)
none
port mirroring is enabled (VM_Network_35_pm)
none
port mirroring is enabled (VM_Network_35_pm)
none
Network was created with two profiles: one for pm and no for not. none

Description Eli Mesika 2013-09-29 12:37:05 UTC
Description of problem:

upgrade script  03_03_0710_add_profile_to_network_interface.sql has the following code :

--START--

Create or replace FUNCTION __temp_has_port_mirroring_vm_interfaces(v_network_id UUID) RETURNS BOOLEAN
   AS $procedure$
BEGIN
   RETURN ((SELECT 1
   FROM vm_interface
   INNER JOIN vm_static
   ON vm_static.vm_guid = vm_interface.vm_guid
   INNER JOIN network_cluster
   ON network_cluster.cluster_id = vm_static.vds_group_id
   INNER JOIN network
   ON network.id = network_cluster.network_id
   AND network.name = vm_interface.network_name
   WHERE network.id = v_network_id
   AND port_mirroring = TRUE) IS NOT NULL);
END; $procedure$
LANGUAGE plpgsql;

--END--

When this function is called, it expects to return one value which is boolean.
On the attached database more than one row is returned and breaks the upgrade as you can see in the log:

psql:upgrade/03_03_0710_add_profile_to_network_interface.sql:80: ERROR:  more than one row returned by a subquery used as an expression
CONTEXT:  SQL statement "SELECT  ((SELECT 1 FROM vm_interface INNER JOIN vm_static ON vm_static.vm_guid = vm_interface.vm_guid INNER JOIN network_cluster ON network_cluster.cluster_id = vm_static.vds_group_id INNER JOIN network ON network.id = network_cluster.network_id AND network.name = vm_interface.network_name WHERE network.id =  $1  AND port_mirroring = TRUE) IS NOT NULL)"
PL/pgSQL function "__temp_has_port_mirroring_vm_interfaces" line 2 at RETURN


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


How reproducible:


Steps to Reproduce:
1. Restore 3.3 database from attached file using pg_restore
2. Try to upgrade manually to 3.3 using upgrade.sh
3.

Actual results:
Upgrade fails with ERROR:  more than one row returned by a subquery used as an expression

Expected results:
Upgrade should complete successfully 

Additional info:

Comment 1 Eli Mesika 2013-09-29 12:41:08 UTC
Created attachment 804672 [details]
3.2 database

Comment 2 Eli Mesika 2013-09-29 12:42:50 UTC
(In reply to Eli Mesika from comment #0)
sorry , should be:

Steps to Reproduce:
1. Restore 3.2 database from attached file using pg_restore
2. Try to upgrade manually to 3.3 using upgrade.sh
3.

Comment 3 awinter 2013-10-02 14:08:06 UTC
Created attachment 806503 [details]
port mirroring is enabled (VM_Network_35_pm)

Comment 4 awinter 2013-10-02 14:09:30 UTC
Created attachment 806504 [details]
port mirroring is enabled (VM_Network_35_pm)

Verified.
Screen shot 1 of 3

Comment 5 awinter 2013-10-02 14:10:47 UTC
Created attachment 806505 [details]
port mirroring is enabled (VM_Network_35_pm)

Verified.
Screen shot 2 of 3

Comment 6 awinter 2013-10-02 14:11:59 UTC
Created attachment 806517 [details]
Network was created with two profiles: one for pm and no for not.

Verified.
Screen shot 3 of 3

Comment 7 awinter 2013-10-02 14:12:47 UTC
Verified.
See attachments.

Comment 9 Itamar Heim 2014-01-21 22:32:17 UTC
Closing - RHEV 3.3 Released

Comment 10 Itamar Heim 2014-01-21 22:32:20 UTC
Closing - RHEV 3.3 Released