Skip to content
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 · 6 comments · Fixed by #3377 or #3434
Closed
Assignees
Labels
Source: Internal PR or issue was opened by an employee Type: Defect
Milestone

Comments

@Danny-Hazelcast
Copy link
Member

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 Using Predicates.between() with PagingPredicate giving incorect results PagingPredicate, - returning duplicated elements, resulting in infinite loop. Aug 11, 2014
@mesutcelik
Copy link

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
Copy link

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
Copy link
Contributor

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
@Danny-Hazelcast
Copy link
Member Author

@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
Copy link
Contributor

mdogan commented Aug 28, 2014

Closed by #3427

@mdogan mdogan closed this as completed 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
@ihsandemir
Copy link
Contributor

related to #9968

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Source: Internal PR or issue was opened by an employee Type: Defect
Projects
None yet
9 participants