Skip to content

Conversation

@dnhatn
Copy link
Member

@dnhatn dnhatn commented Nov 16, 2025

When constructing a very large block, the memory estimate (multiplying two int values) can overflow, yielding a negative value instead of several GB. The negative estimate bypasses the circuit breaker, so the allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once size crosses a threshold we should switch to BigArray. I will address it in a follow-up.

overflow

@elasticsearchmachine
Copy link
Collaborator

Hi @dnhatn, I've created a changelog YAML for you.

@dnhatn dnhatn added v9.2.1 v9.1.8 v8.19.8 auto-backport Automatically create backport pull requests when merged labels Nov 16, 2025
@dnhatn dnhatn marked this pull request as ready for review November 16, 2025 06:45
@elasticsearchmachine elasticsearchmachine added the Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) label Nov 16, 2025
@elasticsearchmachine
Copy link
Collaborator

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

Copy link
Contributor

@ChrisHegarty ChrisHegarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Nhat. LGTM

@dnhatn
Copy link
Member Author

dnhatn commented Nov 17, 2025

@ChrisHegarty @ivancea Thanks for the review!

@dnhatn dnhatn merged commit 8115749 into elastic:main Nov 17, 2025
34 checks passed
@dnhatn dnhatn deleted the fix-memory-estimate branch November 17, 2025 15:05
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Nov 17, 2025
When constructing a very large block, the memory estimate (multiplying 
two int values) can overflow, yielding a negative value instead of
several GB. The negative estimate bypasses the circuit breaker, so the
allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication 
so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once 
size crosses a threshold we should switch to BigArray. I will address it
in a follow-up.
@elasticsearchmachine
Copy link
Collaborator

💚 Backport successful

Status Branch Result
9.2
8.19
9.1

dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Nov 17, 2025
When constructing a very large block, the memory estimate (multiplying 
two int values) can overflow, yielding a negative value instead of
several GB. The negative estimate bypasses the circuit breaker, so the
allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication 
so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once 
size crosses a threshold we should switch to BigArray. I will address it
in a follow-up.
dnhatn added a commit to dnhatn/elasticsearch that referenced this pull request Nov 17, 2025
When constructing a very large block, the memory estimate (multiplying 
two int values) can overflow, yielding a negative value instead of
several GB. The negative estimate bypasses the circuit breaker, so the
allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication 
so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once 
size crosses a threshold we should switch to BigArray. I will address it
in a follow-up.
elasticsearchmachine pushed a commit that referenced this pull request Nov 17, 2025
When constructing a very large block, the memory estimate (multiplying 
two int values) can overflow, yielding a negative value instead of
several GB. The negative estimate bypasses the circuit breaker, so the
allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication 
so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once 
size crosses a threshold we should switch to BigArray. I will address it
in a follow-up.
elasticsearchmachine pushed a commit that referenced this pull request Nov 17, 2025
When constructing a very large block, the memory estimate (multiplying 
two int values) can overflow, yielding a negative value instead of
several GB. The negative estimate bypasses the circuit breaker, so the
allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication 
so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once 
size crosses a threshold we should switch to BigArray. I will address it
in a follow-up.
elasticsearchmachine pushed a commit that referenced this pull request Nov 17, 2025
When constructing a very large block, the memory estimate (multiplying 
two int values) can overflow, yielding a negative value instead of
several GB. The negative estimate bypasses the circuit breaker, so the
allocation proceeds and may lead to OOM.

This change fixes the overflow by casting to long before multiplication 
so the breaker can trigger correctly.

We should avoid allocating a gigantic contiguous primitive array; once 
size crosses a threshold we should switch to BigArray. I will address it
in a follow-up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-backport Automatically create backport pull requests when merged >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.8 v9.1.8 v9.2.1 v9.3.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants