Skip to content

ArrayIndexOutOfBoundsException in TDigest library #111065

@smalyshev

Description

@smalyshev

Elasticsearch Version

8.16.0

Installed Plugins

No response

Java Version

17.0.11

OS Version

Darwin 23.5.0

Problem Description

While doing some tests with TDigest library (https://github.com/elastic/elasticsearch/tree/main/libs/tdigest) and I am getting this:

java.lang.ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 30

when using low compression settings. The code:

TDigest td = TDigest.createMergingDigest(10);  
for(int i=0; i<1_000_000;i++) {  
    td.add(between(0, 3_600_000));  
}

If I use compression setting of 20, it does not happen.

Steps to Reproduce

Just running this code:

TDigest td = TDigest.createMergingDigest(10);
for(int i=0; i<1_000_000;i++) {
td.add(between(0, 3_600_000));
}


### Logs (if relevant)

java.lang.ArrayIndexOutOfBoundsException: Index 30 out of bounds for length 30

at __randomizedtesting.SeedInfo.seed([84E0D3DB44015BF7:7ABC623A61BC3D68]:0)
at org.elasticsearch.tdigest.MergingDigest.merge(MergingDigest.java:325)
at org.elasticsearch.tdigest.MergingDigest.mergeNewValues(MergingDigest.java:247)
at org.elasticsearch.tdigest.MergingDigest.mergeNewValues(MergingDigest.java:237)
at org.elasticsearch.tdigest.MergingDigest.add(MergingDigest.java:222)
at org.elasticsearch.tdigest.TDigest.add(TDigest.java:105)
at org.elasticsearch.search.ccs.CrossClusterSearchIT.testTDigest(CrossClusterSearchIT.java:744)	
(ignore the last line it's just random test to which I've attached the code to run it)

Metadata

Metadata

Assignees

No one assigned

    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