Skip to content

[Bug] (fe) int overflow in BeIdComparator causes stream load failure #63562

@zhangrq5

Description

@zhangrq5

Search before asking

  • I had searched in the issues and found no similar issues.

Version

3.0.4 (Integrated Storage Compute)

What's Wrong?

When executing stream load through the FE HTTP entry (LoadAction.executeWithClusterToken), FE intermittently throws IllegalArgumentException: Comparison method violates its general contract! from SystemInfoService#selectBackendIdsByPolicy, and the stream load request fails to be redirected to a BE.
Stack trace:
2026-04-09 00:08:03,223 WARN (qtp1996111320-135187|155) [LoadAction.executeWithClusterToken():658] Failed to execute stream load with cluster token, Comparison method violates its general contract! 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:1307) ~[?:?] at java.util.ArrayList.sort(ArrayList.java:1721) ~[?:?] at java.util.Collections.sort(Collections.java:179) ~[?:?] at org.apache.doris.system.SystemInfoService.selectBackendIdsByPolicy(SystemInfoService.java:639) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.httpv2.rest.LoadAction.selectLocalRedirectBackend(LoadAction.java:439) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.httpv2.rest.LoadAction.selectRedirectBackend(LoadAction.java:418) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.httpv2.rest.LoadAction.executeWithClusterToken(LoadAction.java:628) ~[doris-fe.jar:1.2-SNAPSHOT] at org.apache.doris.httpv2.rest.LoadAction.streamLoad(LoadAction.java:141) ~[doris-fe.jar:1.2-SNAPSHOT]

What You Expected?

BeIdComparator should return a strictly correct ordering of backend ids regardless of their magnitude, and selectBackendIdsByPolicy should not throw Comparison method violates its general contract!. Stream load should not fail due to this code path.

How to Reproduce?

This is hit on a long-running production cluster:

Cluster has been running for more than 1 year, scaled from 200 BEs to 400 BEs.
10+ hourly-partitioned tables whose bucket count scales with BE count → partitions / tablets roll over very fast → FE metadata ids grow quickly.
Current BE id range:
smallest BE id: 1758683807578
largest BE id: 1773829531020
diff: 15145723442, far greater than Integer.MAX_VALUE (2147483647)
So in BeIdComparator#compare:
a.id - b.id = 15145723442 (long) (int) 15145723442 → wrong sign after truncation

Anything Else?

No response

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions