8000 Comparison method violates its general contract. · Issue #59370 · StarRocks/starrocks · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
Comparison method violates its general contract. #59370
Closed
@wuxueyang96

Description

@wuxueyang96
com.starrocks.sql.common.DmlException: Refresh materialized view ads_play_basic_dev_educ_view_week failed after retrying 1 times(try-lock 0 times), error-msg : Comparison method violates its general contract!
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedViewWithRetry(PartitionBasedMvRefreshProcessor.java:395) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doMvRefresh(PartitionBasedMvRefreshProcessor.java:326) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.processTaskRun(PartitionBasedMvRefreshProcessor.java:200) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.TaskRun.executeTaskRun(TaskRun.java:257) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.TaskRunExecutor.lambda$executeTaskRun$0(TaskRunExecutor.java:57) ~[starrocks-fe.jar:?]
	at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1700) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[?:?]
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[?:?]
	at java.lang.Thread.run(Thread.java:829) ~[?:?]
Caused by: java.lang.IllegalArgumentException: Comparison method violates its general contract!
	at java.util.TimSort.mergeHi(TimSort.java:903) ~[?:?]
	at java.util.TimSort.mergeAt(TimSort.java:520) ~[?:?]
	at java.util.TimSort.mergeCollapse(TimSort.java:448) ~[?:?]
	at java.util.TimSort.sort(TimSort.java:245) ~[?:?]
	at java.util.Arrays.sort(Arrays.java:1515) ~[?:?]
	at java.util.stream.SortedOps$SizedRefSortingSink.end(SortedOps.java:353) ~[?:?]
	at java.util.stream.Sink$ChainedReference.end(Sink.java:258) ~[?:?]
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485) ~[?:?]
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[?:?]
	at java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:913) ~[?:?]
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[?:?]
	at java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:578) ~[?:?]
	at com.starrocks.sql.common.PRangeCellPlus.toPRangeCellPlus(PRangeCellPlus.java:78) ~[starrocks-fe.jar:?]
	at com.starrocks.sql.common.RangePartitionDiffer.generateBaseRefMap(RangePartitionDiffer.java:464) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.mv.MVPCTRefreshRangePartitioner.syncAddOrDropPartitions(MVPCTRefreshRangePartitioner.java:126) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.syncPartitions(PartitionBasedMvRefreshProcessor.java:876) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedView(PartitionBasedMvRefreshProcessor.java:419) ~[starrocks-fe.jar:?]
	at com.starrocks.scheduler.PartitionBasedMvRefreshProcessor.doRefreshMaterializedViewWithRetry(PartitionBasedMvRefreshProcessor.java:367) ~[starrocks-fe.jar:?]

Steps to reproduce the behavior (Required)

Write an unit tests like below:

@Test
public void testComparison() throws AnalysisException {
    final String partitionName = "p1";
    final PartitionKey key1 = PartitionKey.ofDateTime(LocalDateTime.of(2025, 5, 27, 10, 0, 0));
    final PartitionKey key2 = PartitionKey.ofDateTime(LocalDateTime.of(2025, 5, 27, 11, 0, 0));
    final PartitionKey key3 = PartitionKey.ofDateTime(LocalDateTime.of(2025, 5, 27, 12, 0, 0));
    final PartitionKey key4 = PartitionKey.ofDateTime(LocalDateTime.of(2025, 5, 27, 13, 0, 0));

    Range<PartitionKey> r1 = Range.closed(key1, key2);
    PRangeCellPlus cell1 = new PRangeCellPlus(partitionName, r1);
    Assert.assertEquals(0, cell1.compareTo(cell1));

    Range<PartitionKey> r2 = Range.closed(key2, key3);
    PRangeCellPlus cell2 = new PRangeCellPlus(partitionName, r2);
    Assert.assertEquals(-1, cell1.compareTo(cell2));
    Assert.assertEquals(1, cell2.compareTo(cell1));

    Range<PartitionKey> r3 = Range.closed(key3, key4);
    PRangeCellPlus cell3 = new PRangeCellPlus(partitionName, r3);
    Assert.assertEquals(-1, cell2.compareTo(cell3));
    Assert.assertEquals(1, cell3.compareTo(cell2));
    Assert.assertEquals(-1, cell1.compareTo(cell3));
    Assert.assertEquals(1, cell3.compareTo(cell1));

    Range<PartitionKey> r4 = Range.closed(key1, key4);
    PRangeCellPlus cell4 = new PRangeCellPlus(partitionName, r4);
    PRangeCellPlus cell5 = new PRangeCellPlus(partitionName, r3);
    PRangeCellPlus cell6 = new PRangeCellPlus(partitionName, r1);
    Assert.assertEquals(0, cell4.compareTo(cell5));
    Assert.assertEquals(0, cell4.compareTo(cell6));
    Assert.assertEquals(0, cell5.compareTo(cell6));
}

It's easy to get a result like below:

[ERROR] testComparison  Time elapsed: 0.553 s  <<< FAILURE!
java.lang.AssertionError: expected:<0> but was:<1>
        at com.starrocks.sql.common.PRangeCellPlusTest.testComparison(PRangeCellPlusTest.java:56)

Expected behavior (Required)

For comparison, we must ensure that when c1 is equal to c2 and c2 is equal to c3, c1 must be equal to c3.

Real behavior (Required)

Currently, when c1 is equal to c2 and c2 is equal to c3, c1 might be not equal to c3.

StarRocks version (Required)

  • 3.3.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0