Repository navigation
fix: subtract emitted memory size in MinMaxStructState::emit_to(EmitTo::First) - #27115
Open
dragonknightk wants to merge 1 commit into
Open
dragonknightk wants to merge 1 commit into
dragonknightk wants to merge 1 commit into
Conversation
…o::First) Grouped `max`/`min` over structs with ordered aggregation can fail with Resources exhausted even when the data is small. When groups are emitted, the memory accounting subtracts the row count instead of the byte size, so emitted groups keep being counted. Specifically, `MinMaxStructState` tracks the memory of stored values in `total_data_bytes` via `get_array_memory_size()`, but `EmitTo::First(n)` subtracted the `len()` of the emitted values, which is only 1 per group. Ordered aggregation calls `First(n)` after every batch, so the reported size grows with the number of groups seen. Subtract `get_array_memory_size()` of the emitted values instead. Added a sqllogictest that fails with Resources exhausted before the fix and returns the correct result after it, plus a unit test. Closes issue 26891
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Rationale for this change
Grouped
max/minover structs with ordered aggregation can fail with Resources exhausted even when the data is small. When groups are emitted, the memory accounting subtracts the row count instead of the byte size, so emitted groups keep being counted.Specifically,
MinMaxStructStatetracks the memory of stored values intotal_data_bytesviaget_array_memory_size(), butEmitTo::First(n)subtracted thelen()of the emitted values, which is only 1 per group. Ordered aggregation callsFirst(n)after every batch, so the reported size grows with the number of groups seen.What changes are included in this PR?
Subtract
get_array_memory_size()of the emitted values instead.What is the testing strategy for this PR?
Added a sqllogictest in
ordered_aggregate_spill.sltthat fails with Resources exhausted before the fix and returns the correct result after it, plus a unit test.Are there any user-facing changes?
No API changes.