Skip to content

Commit d8d94a9

Browse files
committed
Fix the bug
1 parent ac04e86 commit d8d94a9

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

x-pack/plugin/esql/compute/src/main/java/org/elasticsearch/compute/lucene/ValuesSourceReaderOperator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,7 +681,12 @@ public BlockLoader.Builder nulls(int expectedCount) {
681681

682682
@Override
683683
public Block constantNulls() {
684-
if (nullBlock == null) {
684+
// Avoid creating a new null block if we already have one.
685+
// However, downstream operators take ownership of the null block we hand to them and may close it, forcing us to create a new
686+
// one.
687+
// This could be avoided altogether if this factory itself kept a reference to the null block, but we'd have to also ensure
688+
// to release this block once the factory is not used anymore.
689+
if (nullBlock == null || nullBlock.isReleased()) {
685690
nullBlock = factory.newConstantNullBlock(pageSize);
686691
} else {
687692
nullBlock.incRef();

0 commit comments

Comments
 (0)