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

IllegalArgumentException when ResultSet.getMergeCost() changes during query #41

Open
GoogleCodeExporter opened this issue Jun 15, 2015 · 3 comments

Comments

@GoogleCodeExporter
Copy link

The stacktrace is:

Caused by: java.lang.IllegalArgumentException: Comparison method violates its 
general contract!
        at java.util.TimSort.mergeLo(TimSort.java:747) [rt.jar:1.7.0_71]
        at java.util.TimSort.mergeAt(TimSort.java:483) [rt.jar:1.7.0_71]
        at java.util.TimSort.mergeCollapse(TimSort.java:410) [rt.jar:1.7.0_71]
        at java.util.TimSort.sort(TimSort.java:214) [rt.jar:1.7.0_71]
        at java.util.TimSort.sort(TimSort.java:173) [rt.jar:1.7.0_71]
        at java.util.Arrays.sort(Arrays.java:659) [rt.jar:1.7.0_71]
        at java.util.Collections.sort(Collections.java:217) [rt.jar:1.7.0_71]
        at com.googlecode.cqengine.resultset.connective.ResultSetIntersection.<init>(ResultSetIntersection.java:41) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl.retrieveRecursive(QueryEngineImpl.java:330) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl$2$1.next(QueryEngineImpl.java:351) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl$2$1.next(QueryEngineImpl.java:333) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.resultset.connective.ResultSetIntersection.<init>(ResultSetIntersection.java:38) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl.retrieveRecursive(QueryEngineImpl.java:330) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl$2$1.next(QueryEngineImpl.java:351) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl$2$1.next(QueryEngineImpl.java:333) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.resultset.connective.ResultSetIntersection.<init>(ResultSetIntersection.java:38) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl.retrieveRecursive(QueryEngineImpl.java:330) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.engine.impl.QueryEngineImpl.retrieve(QueryEngineImpl.java:241) [cqengine-1.3.2.jar:]
        at com.googlecode.cqengine.collection.impl.ConcurrentIndexedCollection.retrieve(ConcurrentIndexedCollection.java:79) [cqengine-1.3.2.jar:]

It's hard to reproduce, but it looks like it's happening when one thread is 
executing a query at the same time another thread is modifying the 
ConcurrentIndexedCollection. The simple workaround is to add 
-Djava.util.Arrays.useLegacyMergeSort=true to revert back to the pre-Java 7 
mergesort that silently ignored Comparators that broke the contract, however, 
it would probably be better to somehow take a snapshot of the size of the 
underlying Set (or whatever other method is being used to determine the merge 
cost for a particular ResultSet) so it can't change during the sort.

Further discussion here: 
https://groups.google.com/forum/#!topic/cqengine-discuss/dixsmISmbx8

Original issue reported on code.google.com by bkr...@tapheaven.com on 7 Apr 2015 at 2:38

@GoogleCodeExporter
Copy link
Author

Thanks, this will be fixed in the next version.

Original comment by ni...@npgall.com on 7 Apr 2015 at 3:27

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

This issue was closed by revision r795.

Original comment by ni...@npgall.com on 7 Apr 2015 at 5:24

  • Changed state: Fixed

@GoogleCodeExporter
Copy link
Author

This fix is included in CQEngine 2.0.

Original comment by ni...@npgall.com on 21 Apr 2015 at 11:16

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

No branches or pull requests

1 participant