Skip to content

release-26.1: opt/memo: fix exponential behavior when formatting nested UDFs#166131

Merged
yuzefovich merged 1 commit intocockroachdb:release-26.1from
yuzefovich:blathers/backport-release-26.1-166026
Mar 19, 2026
Merged

release-26.1: opt/memo: fix exponential behavior when formatting nested UDFs#166131
yuzefovich merged 1 commit intocockroachdb:release-26.1from
yuzefovich:blathers/backport-release-26.1-166026

Conversation

@yuzefovich
Copy link
Copy Markdown
Member

@yuzefovich yuzefovich commented Mar 19, 2026

Backport 1/1 commits from #166026 on behalf of @yuzefovich.


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.

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.

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.
@yuzefovich yuzefovich requested a review from a team as a code owner March 19, 2026 04:01
@yuzefovich yuzefovich requested review from michae2 and removed request for a team March 19, 2026 04:01
@blathers-crl blathers-crl Bot added blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. labels Mar 19, 2026
@blathers-crl blathers-crl Bot requested a review from DrewKimball March 19, 2026 04:01
@blathers-crl
Copy link
Copy Markdown

blathers-crl Bot commented Mar 19, 2026

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.

@blathers-crl blathers-crl Bot added backport Label PR's that are backports to older release branches T-sql-queries SQL Queries Team labels Mar 19, 2026
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@yuzefovich yuzefovich requested review from mw5h and removed request for DrewKimball and michae2 March 19, 2026 04:05
@yuzefovich yuzefovich merged commit bb10ada into cockroachdb:release-26.1 Mar 19, 2026
20 checks passed
@yuzefovich yuzefovich deleted the blathers/backport-release-26.1-166026 branch March 19, 2026 20:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Label PR's that are backports to older release branches blathers-backport This is a backport that Blathers created automatically. O-robot Originated from a bot. T-sql-queries SQL Queries Team target-release-26.1.4

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants