Skip to content

Commit 1ad8eb4

Browse files
committed
More test fixes
1 parent cfbf4b2 commit 1ad8eb4

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/data/DocVector.java

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,15 @@ public DocVector(
8282
"invalid position count [" + shards.getPositionCount() + " != " + docs.getPositionCount() + "]"
8383
);
8484
}
85-
86-
this.uniqueShards = computeUniqueShards(shards);
87-
forEachShardRefCounter(RefCounted::mustIncRef);
88-
blockFactory().adjustBreaker(BASE_RAM_BYTES_USED);
85+
var uniqueShards = computeUniqueShards(shards);
86+
try {
87+
blockFactory().adjustBreaker(BASE_RAM_BYTES_USED);
88+
this.uniqueShards = uniqueShards;
89+
forEachShardRefCounter(RefCounted::mustIncRef);
90+
} catch (Exception e) {
91+
Releasables.close(uniqueShards);
92+
throw e;
93+
}
8994
}
9095

9196
private static IntVector computeUniqueShards(IntVector shards) {
@@ -359,20 +364,21 @@ public long ramBytesUsed() {
359364
public void allowPassingToDifferentDriver() {
360365
super.allowPassingToDifferentDriver();
361366
shards.allowPassingToDifferentDriver();
367+
uniqueShards.allowPassingToDifferentDriver();
362368
segments.allowPassingToDifferentDriver();
363369
docs.allowPassingToDifferentDriver();
364370
}
365371

366372
@Override
367373
public void closeInternal() {
374+
forEachShardRefCounter(RefCounted::decRef);
368375
Releasables.closeExpectNoException(
369376
() -> blockFactory().adjustBreaker(-BASE_RAM_BYTES_USED - (shardSegmentDocMapForwards == null ? 0 : sizeOfSegmentDocMap())),
370377
shards,
371378
uniqueShards,
372379
segments,
373380
docs
374381
);
375-
forEachShardRefCounter(RefCounted::decRef);
376382
}
377383

378384
private void forEachShardRefCounter(Consumer<RefCounted> consumer) {

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/Driver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ private int closeEarlyFinishedOperators(ListIterator<Operator> operators) {
317317
if (iterator.previous().isFinished()) {
318318
var index = iterator.nextIndex();
319319
/*
320-
* Remove this operator and all source operators in the
320+
* Close and remove this operator and all source operators in the
321321
* most paranoid possible way. Closing operators shouldn't throw,
322322
* but if it does, this will make sure we don't try to close any
323323
* that succeed twice.

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/operator/OrdinalsGroupingOperator.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ static final class OrdinalSegmentAggregator implements Releasable, SeenGroupIds
357357
RefCounted shardRefCounted
358358
) throws IOException {
359359
boolean success = false;
360-
shardRefCounted.mustIncRef();
361360
this.shardRefCounted = shardRefCounted;
361+
this.shardRefCounted.mustIncRef();
362362
List<GroupingAggregator> groupingAggregators = null;
363363
BitArray bitArray = null;
364364
try {
@@ -370,7 +370,6 @@ static final class OrdinalSegmentAggregator implements Releasable, SeenGroupIds
370370
this.docValuesSupplier = docValuesSupplier;
371371
this.aggregators = groupingAggregators;
372372
this.visitedOrds = bitArray;
373-
this.shardRefCounted.mustIncRef();
374373
success = true;
375374
} finally {
376375
if (success == false) {

0 commit comments

Comments
 (0)