samklr / cqengine

Automatically exported from code.google.com/p/cqengine
0 stars 0 forks source link

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

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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 commented 9 years ago
Thanks, this will be fixed in the next version.

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

GoogleCodeExporter commented 9 years ago
This issue was closed by revision r795.

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

GoogleCodeExporter commented 9 years ago
This fix is included in CQEngine 2.0.

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