New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PagingPredicate, - returning duplicated elements, resulting in infinite loop. #3047

Closed
Danny-Hazelcast opened this Issue Jul 22, 2014 · 5 comments

Comments

Projects
None yet
7 participants
@Danny-Hazelcast
Member

Danny-Hazelcast commented Jul 22, 2014

RP #3042 show Junit test for this issue.

issue first discovered while making a stabilizer test, around queries and indexes.

looks like range predicates, run on a map with Ordered Indexes, don't work as expected

@gurbuzali gurbuzali self-assigned this Jul 22, 2014

@gurbuzali gurbuzali added this to the 3.2.5 milestone Jul 22, 2014

@mdogan mdogan modified the milestones: 3.2.5, 3.2.6 Aug 6, 2014

@Danny-Hazelcast Danny-Hazelcast changed the title from Using Predicates.between() with PagingPredicate giving incorect results to PagingPredicate, - returning duplicated elements, resulting in infinite loop. Aug 11, 2014

@mesutcelik

This comment has been minimized.

Contributor

mesutcelik commented Aug 11, 2014

related failing tests on master.
https://hazelcast-l337.ci.cloudbees.com/job/Hazelcast-3.x-problematicTest/214/com.hazelcast$hazelcast-client/testReport/

It seems the issue must be forward ported to the master branch.

 com.hazelcast.client.map.ClientSortLimitTest.mapPagingPredicate_EmployObject_WithOrderedIndex_smalltest    0.19 sec    1
 com.hazelcast.client.map.ClientSortLimitTest.mapPagingPredicate_EmployObject_WithOrderedIndex_largetest    4.6 sec 1
 com.hazelcast.client.map.ClientSortLimitTest.equalsPred_withEmploye_test   1 min 0 sec 2
 com.hazelcast.client.map.ClientSortLimitTest.betweenPaginPred_withEmploye_test 1 min 0 sec 2
 com.hazelcast.client.map.ClientSortLimitTest.lessThanPred_withEmploye_test
@awara2012

This comment has been minimized.

awara2012 commented Aug 12, 2014

Maybe the method -- "hashCode()"(it's called in the "SortingUtil.compare()".), inheriting from the "Object", is the cause of the incorrect result when using the "PagingPredicate". (The hash code of the same "anchor" in the same "PagingPredicate" will be different at two query requests.)

@enesakar enesakar modified the milestones: 3.2.6, 3.3 Aug 14, 2014

@gurbuzali gurbuzali assigned serkan-ozal and unassigned gurbuzali Aug 18, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 20, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 20, 2014

@serkan-ozal

This comment has been minimized.

Contributor

serkan-ozal commented Aug 23, 2014

The issue is about the wrong hashcode comparison.

Suppose that
i1 = -500.000.000
i2 = 2.000.000.000

Normally "i1 < i2", but if we use "i1 - i2" for comparison
i1 - i2 = -500.000.000 - 2.000.000.000 and we may accept result as "-2.500.000.000".
But the actual result is "1.794.967.296" because of overflow between
positive and negative integer bounds.

So, if we use "i1 - i2" for comparison, since result is greater than 0,
"i1" is accepted as bigger that "i2". But in fact "i1" is smaller than "i2".
Therefore, "i1 - i2" is not good way for comparison way between signed integers.

So comparison must be like this

...
int result = compareIntegers(comparable1.hashCode(), comparable2.hashCode());
...
private static int compareIntegers(int i1, int i2) {
        // "return i1 - i2" is not good way for comparison
        if (i1 > i2) {
            return +1;
        } else if (i2 > i1) {
            return -1;
        } else {
            return 0;
        }
}

Please see PR #3334

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 23, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 23, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 23, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 23, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 23, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 25, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 25, 2014

@mdogan mdogan closed this in #3377 Aug 25, 2014

@Danny-Hazelcast

This comment has been minimized.

Member

Danny-Hazelcast commented Aug 27, 2014

@serkan-ozal @mdogan
I am reopening this issue as paging predicates are still broken,
see this PR #3409 for updated tests

looks like paging predicate is still producing duplicate results

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

Serdaro added a commit that referenced this issue Aug 28, 2014

@mdogan

This comment has been minimized.

Member

mdogan commented Aug 28, 2014

Closed by #3427

@mdogan mdogan closed this Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

serkan-ozal pushed a commit to serkan-ozal/hazelcast that referenced this issue Aug 28, 2014

@mdogan mdogan modified the milestones: 3.3, 3.2.6 Aug 29, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment