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

Bug 1540814

Summary: upgrade dbscript fails if multiplication overflows
Product: Red Hat Enterprise Virtualization Manager Reporter: Doran Moppert <dmoppert>
Component: ovirt-engineAssignee: Shmuel Melamud <smelamud>
Status: CLOSED ERRATA QA Contact: Jiri Belka <jbelka>
Severity: medium Docs Contact:
Priority: unspecified    
Version: 4.1.10CC: apinnick, dmoppert, lsurette, lsvaty, lveyde, michal.skrivanek, rbalakri, Rhev-m-bugs, srevivo, ykaul, ylavi
Target Milestone: ovirt-4.2.2   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: ovirt-engine-4.2.2 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2018-05-15 17:48:28 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 Doran Moppert 2018-02-01 05:16:45 UTC
Attempting to upgrade when vm_static.mem_size_db contains a value exceeding (2**29-1) fails with the error "integer out of range", leaving the engine down until manual intervention is performed.  This was originally reported as a side effect of the testing taken in bug 1496602.

The offending query is:

/usr/share/ovirt-engine/dbscripts/upgrade/04_01_0640_add_max_memory_size_column.sql
> UPDATE vm_static
>    SET max_memory_size_mb = LEAST(4 * mem_size_mb, 1048576);


A simple fix might be:

> UPDATE vm_static
>    SET max_memory_size_mb = LEAST(4 * LEAST(536870911, mem_size_mb), 1048576);

Comment 2 Yaniv Kaul 2018-02-01 07:53:36 UTC
I thought this was fixed some time ago.
Which version was used?

Comment 3 Doran Moppert 2018-02-02 00:19:29 UTC
(In reply to Yaniv Kaul from comment #2)
> I thought this was fixed some time ago.
> Which version was used?

I don't think this precise issue was fixed.  Original report was using 4.1.5, and I see the script unmodified in 4.1.9 and upstream master.  I have not tried the full upgrade process to verify the problem, but running this script alone still triggers the error under the conditions described.

I do see a related issue fixed upstream in 2016, using a cleaner method than I suggested:

https://gerrit.ovirt.org/#/c/51420/

which suggests the following change in 04_01_0640_add_max_memory_size_column.sql, which works in my tests:

> UPDATE vm_static
>    SET max_memory_size_mb = LEAST(4 * mem_size_mb::bigint, 1048576);

Comment 4 Michal Skrivanek 2018-02-02 06:18:05 UTC
(In reply to Yaniv Kaul from comment #2)
> I thought this was fixed some time ago.

bug 1519811? That's the opposite case. The fix should be trivial

Comment 5 RHV bug bot 2018-02-16 16:24:47 UTC
WARN: Bug status (ON_QA) wasn't changed but the folowing should be fixed:

[Found non-acked flags: '{'rhevm-4.2-ga': '?'}', ]

For more info please contact: rhv-devops: Bug status (ON_QA) wasn't changed but the folowing should be fixed:

[Found non-acked flags: '{'rhevm-4.2-ga': '?'}', ]

For more info please contact: rhv-devops

Comment 6 Jiri Belka 2018-02-23 16:56:26 UTC
ok,

update from ovirt-engine-4.2.1-0.2.el7.noarch to ovirt-engine-4.2.2.1-0.1.el7.noarch

Comment 7 RHV bug bot 2018-03-16 15:02:35 UTC
INFO: Bug status (VERIFIED) wasn't changed but the folowing should be fixed:

[Tag 'ovirt-engine-4.2.2.4' doesn't contain patch 'https://gerrit.ovirt.org/87258']
gitweb: https://gerrit.ovirt.org/gitweb?p=ovirt-engine.git;a=shortlog;h=refs/tags/ovirt-engine-4.2.2.4

For more info please contact: rhv-devops

Comment 11 errata-xmlrpc 2018-05-15 17:48:28 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

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

https://access.redhat.com/errata/RHEA-2018:1488

Comment 12 Franta Kust 2019-05-16 13:08:00 UTC
BZ<2>Jira Resync