Skip to content

Conversation

kanoshiou
Copy link
Contributor

@kanoshiou kanoshiou commented Oct 13, 2025

The root cause was that when aggregate columns are pruned and no grouping columns exist, the optimizer creates a LocalRelation with a ConstantNullBlock page using LocalSupplier.of() (which delegates to ImmediateLocalSupplier), but during inline stats execution, this same page gets referenced and released twice - once when the LocalRelation serves as a source for the left-hand side of the InlineJoin, and again when it continues execution on the right-hand side, causing a double release error and connection closure. The CopyingLocalSupplier prevents this by creating a deep copy of the page on each get() call, ensuring proper memory management when the same LocalRelation is used multiple times in inline stats scenarios.

Closes #136349

- Replace `LocalSupplier.of` with new `CopyingLocalSupplier` in `PruneColumns`
- Add `INLINE_STATS_AFTER_PRUNED_AGGREGATE` capability
- Add test cases for inline stats after aggregate pruning
@elasticsearchmachine elasticsearchmachine added needs:triage Requires assignment of a team area label v9.3.0 external-contributor Pull request authored by a developer outside the Elasticsearch team labels Oct 13, 2025
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Oct 13, 2025
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-analytical-engine (Team:Analytics)

@elasticsearchmachine elasticsearchmachine removed the needs:triage Requires assignment of a team area label label Oct 13, 2025
@bpintea bpintea requested review from astefan and bpintea October 13, 2025 11:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL external-contributor Pull request authored by a developer outside the Elasticsearch team Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ES|QL] Connection closed after dropping most fields after inline stats & stats

3 participants