Itamar Heim has submitted this change and it was merged.
Change subject: fixing integer out of range exception in search
......................................................................
fixing integer out of range exception in search
The change [1] introduced to return all rows when max=-1 generates an
integer overflow in the calculation of the indexes used for paging. For
example, in an environment with one data center running a query with
"page 2" generates the following error:
<fault><reason>Operation Failed</reason><detail>statementcallback;
sql
[select * from (select * from storage pool where ( id in (select storage
pool with storage domain.id from storage pool with storage domain ))
order by name asc ) as t1 offset (-2147483648 -1) limit 2147483647];
error: integer out of range; nested exception is
org.postgresql.util.psqlexception: error: integer out of
range</detail></fault>
The problem is in SyntaxChecker.java, in line 954, where we do the
following:
result = StringFormat.format(pagingSyntax, (page - 1) *
syntax.getMaxCount() + 1, syntax.getMaxCount());
This multiplication results in Integer.MAX_VALUE + 1, which overflows
the integer and results in the value -2147483648.
This affect all uses of queries with paging.
[1]
http://gerrit.ovirt.org/21375
Change-Id: I518dfdfff93dde28d9741d5e333c695239b7e7d2
Signed-off-by: Eli Mesika <emesika(a)redhat.com>
---
M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SearchQuery.java
M
backend/manager/modules/searchbackend/src/main/java/org/ovirt/engine/core/searchbackend/SyntaxChecker.java
2 files changed, 10 insertions(+), 5 deletions(-)
Approvals:
Eli Mesika: Verified
Yair Zaslavsky: Looks good to me, approved
--
To view, visit
http://gerrit.ovirt.org/24240
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I518dfdfff93dde28d9741d5e333c695239b7e7d2
Gerrit-PatchSet: 2
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.4
Gerrit-Owner: Eli Mesika <emesika(a)redhat.com>
Gerrit-Reviewer: Eli Mesika <emesika(a)redhat.com>
Gerrit-Reviewer: Itamar Heim <iheim(a)redhat.com>
Gerrit-Reviewer: Juan Hernandez <juan.hernandez(a)redhat.com>
Gerrit-Reviewer: Yair Zaslavsky <yzaslavs(a)redhat.com>
Gerrit-Reviewer: oVirt Jenkins CI Server