Repository navigation
Fix double destroy of aggregate states when create throws after destroy - #132755
Conversation
…stroy` `AggregateState::recreate` and the `-ArgMin` / `-ArgMax` combinator destroyed a state and created it again in place; if `create` threw, the owner destroyed the state a second time. Track whether the state is alive. Also destroy the already built parts when `create` of `-ArgMin` / `-ArgMax` or `-Distinct` throws. Co-Authored-By: Claude Opus 5.5 <[email protected]>
A review of a diff that added `destroy` then `create` of a nested aggregate state did not flag that a throwing `create` leads to a second `destroy`. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The columns were added to the state after it was constructed in place, so an allocation that threw left them allocated with nobody to destroy them. Build them first and construct the state from them. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Workflow [PR], commit [0a914a9] Summary: ✅
AI ReviewSummaryThe PR prevents double destruction when re-creating window aggregate states or resetting nested states in Final VerdictStatus: ✅ Approve |
Build profile diff (arm_release)Comparing ✅ No significant changes. Binary sizes
The official master build is compiled with Compile time of recompiled translation units1414 translation units recompiled, 48 s compile time in total, 1414 of them have a recent master baseline. |
`checkCreated` was not inlined, so every row paid for a call with a full frame. Inline the test and keep only the throw out of line. Co-Authored-By: Claude Opus 5.5 <[email protected]>
AI review of a later commit does not approve the PR, see the AI Review comment.
`AggregateState` does not exist in this release, so the window part of the fix is ported to `WindowTransform`: the workspace tracks whether its state is alive and skips the second `destroy`. The review skill change is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`AggregateState` does not exist in this release, so the window part of the fix is ported to `WindowTransform`: the workspace tracks whether its state is alive and skips the second `destroy`. The review skill change is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`AggregateState` does not exist in this release, so the window part of the fix is ported to `WindowTransform`: the workspace tracks whether its state is alive and skips the second `destroy`. The review skill change is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
`AggregateState` does not exist in this release, so the window part of the fix is ported to `WindowTransform`: the workspace tracks whether its state is alive and skips the second `destroy`. The review skill change is dropped. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Cherry pick #132755 to 26.3: Fix double destroy of aggregate states when `create` throws after `destroy`
… `create` throws after `destroy`
Cherry pick #132755 to 26.8: Fix double destroy of aggregate states when `create` throws after `destroy`
… `create` throws after `destroy`
Cherry pick #132755 to 26.9: Fix double destroy of aggregate states when `create` throws after `destroy`
… `create` throws after `destroy`
Cherry pick #132755 to 26.10: Fix double destroy of aggregate states when `create` throws after `destroy`
…n `create` throws after `destroy`
Backport #132755 to 26.10: Fix double destroy of aggregate states when `create` throws after `destroy`
Backport #132755 to 26.9: Fix double destroy of aggregate states when `create` throws after `destroy`
Backport #132755 to 26.8: Fix double destroy of aggregate states when `create` throws after `destroy`
Backport #132755 to 26.3: Fix double destroy of aggregate states when `create` throws after `destroy`
When
createof an aggregate state threw (for exampleMEMORY_LIMIT_EXCEEDED) right after the previous state in the same place had been destroyed, the owner destroyed the state a second time. This happened inAggregateState::recreate(aggregate functions used as window functions, on every new partition or frame) and in the-ArgMin/-ArgMaxcombinator when a new extreme key resets the nested state (add,merge, parallel merge). Depending on the state type this is a double free, which crashes the server, e.g. forflameGraph. Both now track whether the state is alive and skip the seconddestroy.createof-ArgMin/-ArgMax,-DistinctandgroupFormatalso leaked the parts already built when a later part threw. They now destroy them before rethrowing.The review skill gets a check for objects destroyed and re-created in place: the AI review missed this pattern when it was added to
-ArgMin/-ArgMax.Related: #132557
Changelog category (leave one):
Changelog entry (a user-readable short description of the changes that goes into CHANGELOG.md):
Fix a crash (double free) when an allocation failed, e.g. because of the memory limit, while an aggregate function used as a window function moved to a new partition or frame, or while an aggregate function with the
-ArgMin/-ArgMaxcombinator reset its state for a new extreme value.Workflow [PR]
Sync PR [sync-upstream/pr/132755]
Version info
26.11.1.2900-master(included in26.11and later)26.10.8.38,26.9.34.18,26.8.42.16,26.3.69.3