release-26.1: opt/memo: fix exponential behavior when formatting nested UDFs#166131
Merged
yuzefovich merged 1 commit intocockroachdb:release-26.1from Mar 19, 2026
Conversation
This commit fixes seemingly exponential behavior when formatting nested UDFs when `ExprFmtHideScalars` flag is not set (which is the case for `EXPLAIN (OPT, TYPES)` and `opt-vv.txt` file of the stmt bundle). This is done by keeping track of "repetitive calls" in addition to already being tracked "recursive calls". Once we've seen a call to a UDF, the UDF's future invocation aren't formatted and are simply replaced with `repetitive-call`. The impact of the old behavior is that it can easily lead to OOMs. For example, running the regression test for issue 161993 via EXPLAIN ANALYZE (DEBUG) on my laptop consumes 50GiB and doesn't finish within 30s. Release note (bug fix): Previously, running `EXPLAIN ANALYZE (DEBUG)` on a query that invokes a UDF with many blocks in some cases could cause OOMs, and this is now fixed.
|
Thanks for opening a backport. Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate. |
Member
mw5h
approved these changes
Mar 19, 2026
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.
Backport 1/1 commits from #166026 on behalf of @yuzefovich.
This commit fixes seemingly exponential behavior when formatting nested UDFs when
ExprFmtHideScalarsflag is not set (which is the case forEXPLAIN (OPT, TYPES)andopt-vv.txtfile of the stmt bundle). This is done by keeping track of "repetitive calls" in addition to already being tracked "recursive calls". Once we've seen a call to a UDF, the UDF's future invocation aren't formatted and are simply replaced withrepetitive-call.The impact of the old behavior is that it can easily lead to OOMs. For example, running the regression test for issue 161993 via EXPLAIN ANALYZE (DEBUG) on my laptop consumes 50GiB and doesn't finish within 30s.
Fixes: #166024.
Release note (bug fix): Previously, running
EXPLAIN ANALYZE (DEBUG)on a query that invokes a UDF with many blocks in some cases could cause OOMs, and this is now fixed.Release justification: low-risk bug fix.