Bug 1540814 - upgrade dbscript fails if multiplication overflows
Summary: upgrade dbscript fails if multiplication overflows
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Virtualization Manager
Classification: Red Hat
Component: ovirt-engine
Version: 4.1.10
Hardware: Unspecified
OS: Unspecified
unspecified
medium
Target Milestone: ovirt-4.2.2
: ---
Assignee: Shmuel Melamud
QA Contact: Jiri Belka
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2018-02-01 05:16 UTC by Doran Moppert
Modified: 2019-05-16 13:08 UTC (History)
11 users (show)

Fixed In Version: ovirt-engine-4.2.2
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2018-05-15 17:48:28 UTC
oVirt Team: Virt
Target Upstream Version:


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHEA-2018:1488 0 None None None 2018-05-15 17:49:44 UTC
oVirt gerrit 87131 0 master MERGED core: Fix integer overflow in max_memory_size_mb calculation 2018-02-06 20:51:59 UTC
oVirt gerrit 87258 0 ovirt-engine-4.2 MERGED core: Fix integer overflow in max_memory_size_mb calculation 2018-02-07 13:06:15 UTC

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@redhat.comINFO: 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@redhat.com

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@redhat.com

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


Note You need to log in before you can comment on or make changes to this bug.