Skip to content

Commit 08b8450

Browse files
authored
ESQL: Unmute test and reuse blockFactory to avoid concurrently modifying the test factories list (#128211) (#128243)
Fixes #128092 The error happens inside an ArrayList.add(), and it's a concurrency-related one. The stacktrace is quite explicative: ``` java.lang.ArrayIndexOutOfBoundsException: Index 34 out of bounds for length 33 at java.util.ArrayList.add(ArrayList.java:485) at org.elasticsearch.compute.test.ComputeTestCase.blockFactory(ComputeTestCase.java:62) at org.elasticsearch.compute.aggregation.GroupingAggregatorFunctionTestCase$4$1$1.addBlock(GroupingAggregatorFunctionTestCase.java:659) ``` We were creating new blockFactories() inside the aggregator, which was being called concurrently with different drivers. As `blockFactory()` adds it to a static ArrayList, it was sometimes throwing. The bug only affects tests. Potentially, all grouping aggregators tests.
1 parent 756773e commit 08b8450

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

x-pack/plugin/esql/compute/src/test/java/org/elasticsearch/compute/aggregation/GroupingAggregatorFunctionTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ public AddInput prepareProcessPage(SeenGroupIds ignoredSeenGroupIds, Page page)
651651
@Override
652652
public void add(int positionOffset, IntBlock groupIds) {
653653
for (int offset = 0; offset < groupIds.getPositionCount(); offset += emitChunkSize) {
654-
try (IntBlock.Builder builder = blockFactory().newIntBlockBuilder(emitChunkSize)) {
654+
try (IntBlock.Builder builder = driverContext.blockFactory().newIntBlockBuilder(emitChunkSize)) {
655655
int endP = Math.min(groupIds.getPositionCount(), offset + emitChunkSize);
656656
for (int p = offset; p < endP; p++) {
657657
int start = groupIds.getFirstValueIndex(p);

0 commit comments

Comments
 (0)