Mohan
11/25/2026, 10:53 AMSELECT
nta.cdr_id,
nta.analyzed_at,
STR_TO_DATE(
REPLACE(get_json_string(nta.json_response, '$.followup_time_readable'), ' IST', ''),
'%d %b %Y, %h:%i %p'
) AS followup_due_ai,
get_json_string(nta.json_response, '$.followup_time_readable') AS followup_time_readable,
CAST(get_json_string(nta.json_response, '$.follow_up_time_in_min') AS BIGINT) AS follow_up_time_in_min,
get_json_string(nta.json_response, '$.callback_discussed') AS callback_discussed,
get_json_string(nta.json_response, '$.callback_direction') AS callback_direction,
get_json_string(nta.json_response, '$.alignment_level') AS alignment_level,
get_json_string(nta.json_response, '$.cx_requested_no_callback') AS cx_requested_no_callback,
get_json_string(nta.json_response, '$.followup_time_capped') AS followup_time_capped,
COALESCE(
get_json_string(nta.json_response, '$.company_reimbursed_movement'),
'Not Identified'
) AS company_reimbursed_movement,
ROW_NUMBER() OVER (PARTITION BY nta.cdr_id ORDER BY nta.analyzed_at DESC) AS rn
FROM <db>.transcripts nta
WHERE nta.use_case = 'PNM_Expected_follow_ups'
AND nta.analyzed_at < UNIX_TIMESTAMP('2026-11-01') * 1000
AND nta.analyzed_at >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE(), INTERVAL 120 DAY)) * 1000
AND COALESCE(get_json_string(nta.json_response, '$.is_voicemail'), 'false') <> 'true'
giving error Memory of process exceed limit. try consume:90071992547409920 Backend: starrocks-cn-7.starrocks-cn-search.starrocks-shared.svc.cluster.local, Used: 30526856768, Limit: 156551557939. Mem usage has exceed the limit of BE: BE:7632382Rocky
11/25/2026, 10:54 AMMemory of process exceed limit is the whole CN process tracker rejecting an allocation, not a per-query limit. That tracker's limit is 90% of BE config mem_limit, and mem_limit defaults to 90% of physical memory — so Limit: 156551557939 (~146 GiB) is consistent with a machine of roughly 180 GiB. Nothing unusual there.
Your numbers say it is not real memory pressure
• Used: 30526856768 ≈ 28.4 GiB against a 146 GiB limit — the node was nowhere near full.
• try consume:90071992547409920 ≈ 80 petabytes, and it's exactly 10 × 2^53 (2^53 = 9007199254740992, the double-precision integer limit).
A request of 10×2^53 bytes is not a real data size — it looks like an internally computed size that overflowed or was never initialized. So my read is: this is a bug/edge case in 4.0.8's execution path, not your JSON payloads being large and not memory exhaustion. I can't tell you from the docs which code path it is, though — the message's second line (try consume, the absurd value) is what points away from genuine pressure.
Why the CNs restart — I can't confirm this
The docs don't document "all CNs restart" as a consequence of this error, so treat this as possibilities, not fact:
• The process being killed by the OS/kubelet OOM killer (check dmesg, k8s OOMKilled / restart events, and whether the CN log ends abruptly vs. logging the error and continuing).
• A shared-data CN that restarts in a loop without a crash stack while emitting exactly Memory of process exceed limit is a documented known issue — but for lake compaction, fixed in 4.1.7 and not yet released on the 4.0 line. That one is driven by compaction, not your query, so it may explain restarts you see even if it isn't the cause of this query's failure.
What I'd do next
1. Isolate the trigger — trim the select list progressively: (a) only the 9 get_json_string projections, no window function; (b) the full list but replace ROW_NUMBER() OVER (...) with nothing; (c) swap the STR_TO_DATE(REPLACE(...)) expression out. Cheap, and tells you whether it's the window operator or the JSON extraction.
2. Turn on the large-column checker — SET pipeline_enable_large_column_checker = true (BE config, mutable). It only became default-on in 4.0.11, so on 4.0.8 it's off. It's designed to make an intermediate column hitting the chunk capacity limit fail cleanly with a capacity error instead of attempting a giant allocation.
3. Check http://starrocks-cn-7...:<http_port>/mem_tracker while the query runs, to confirm query_pool is not actually the large child and it really is a bogus single allocation.
4. Move to the latest 4.0.x patch. 4.0.8 is well behind; the 4.0 release notes contain several memory/restart fixes, including one in the same bug class as yours (a serialization buffer sized as widest-row × chunk size, producing try consume:549755813888 — fixed in 4.0.16) and JSON subfield rewrite fixes in 4.0.17. I cannot promise any of those is your defect; please scan the 4.0 release notes for the versions between 4.0.8 and current.
5. If it reproduces on the latest 4.0.x, capture the CN `be.out`/`be.WARNING` around the failure plus the query profile and open a GitHub issue. That's the right channel for a defect like this — and the community Slack if you want a maintainer's eye on it quickly.
One caveat worth flagging: what you're hitting is genuinely undiagnosed in the public docs. Given that the allocation size is garbage-level rather than large, I'd stop rerunning the query as-is — if the failure is what's taking the CNs down, each retry is a fresh restart.
References
• knowledge/known_issues/query.md (StarRocks knowledge base)
• sql-reference/data-types/semi_structured/JSON.mdRocky
11/25/2026, 10:54 AMMohan
11/25/2026, 10:57 AMRocky
11/25/2026, 10:57 AMpipeline_enable_large_column_checker only became default-on in 4.0.11. That's wrong — the docs say default true, introduced in v4.0.0 (it was false only on 3.5). So on 4.0.8 it's already on, and enabling it isn't an option for you. Ignore step 2 of my previous answer. The fact that you're not getting a "capacity limit exceeded" error also tells us your failure isn't taking the large-column-checker path at all.
Is there a memory leak?
Almost certainly not, and the numbers argue against it:
• A leak shows as Used creeping up toward Limit. You saw 28 GiB used of 146 GiB.
• The rejected allocation was 80 petabytes — a meaningless size, not a big one.
A leak also wouldn't be triggered by one specific query shape. What you have looks like a bad size computation in one operator on one code path. I can't name the code path from the docs, so treat that as inference.
If you want to rule a leak out properly: poll /mem_tracker and /memz on an idle CN over ~30 min. Flat = no leak. Monotonic growth = a leak candidate — one known leak of that shape (RPC stub cache timers) is fixed in 4.0.14.
What to actually try, in order
1. Turn off the JSON path rewrite for this query — this is the highest-value single test, and it's a documented workaround, not a guess:
sql
SET cbo_json_v2_rewrite = false;
cbo_json_v2_rewrite is on by default since 4.0 and rewrites get_json_* into direct Flat JSON subcolumn access. The documented known issue for that rewrite includes crashing the BE process when scans read one path at different types; the workaround given is exactly cbo_json_v2_rewrite=false, fixed in 4.0.17 / 4.1.7 (PR #78611). Your case involves 11 get_json_string paths, several repeated ($.followup_time_readable twice, $.is_voicemail in the WHERE) — if json_response is a JSON-typed column, all of those go through the rewrite. If disabling it makes the query run, you've found your culprit.
Also check DESC <db>.transcripts — if json_response is VARCHAR, not JSON, the rewrite doesn't apply and every one of those 11 calls re-parses the text. Cast once and extract from the cast value.
2. Restructure so wide rows never sit in the sort/exchange buffer. Your ROW_NUMBER() OVER (PARTITION BY cdr_id ORDER BY analyzed_at DESC) sorts rows that carry json_response plus 10 output strings. Narrow it first, filter rn = 1 (you currently compute rn and never use it — the window is pure overhead unless an outer query filters), and do the JSON extraction after:
sql
WITH ranked AS (
SELECT cdr_id, analyzed_at, json_response
FROM <db>.transcripts
WHERE use_case = 'PNM_Expected_follow_ups'
AND analyzed_at < UNIX_TIMESTAMP('2026-11-01') * 1000
AND analyzed_at >= UNIX_TIMESTAMP(DATE_SUB(CURRENT_DATE(), INTERVAL 120 DAY)) * 1000
AND COALESCE(get_json_string(json_response, '$.is_voicemail'), 'false') <> 'true'
)
SELECT r.cdr_id, r.analyzed_at,
STR_TO_DATE(REPLACE(get_json_string(r.json_response, '$.followup_time_readable'), ' IST', ''),
'%d %b %Y, %h:%i %p') AS followup_due_ai,
... -- same projections, one extraction per path
FROM (SELECT *, ROW_NUMBER() OVER (PARTITION BY cdr_id ORDER BY analyzed_at DESC) AS rn FROM ranked) r
WHERE r.rn = 1;
3. Upgrade. 4.0.8 is far behind current 4.0.x. Directly relevant patches on the 4.0 line: 4.0.17 (the JSON subfield rewrite fix), 4.0.16 (serialization-buffer sizing fix — a huge bogus try consume value, same bug class as yours), 4.0.14 (cleaned-up capacity-limit message plus the RPC-stub leak fix), 4.0.12 (Flat JSON flush SIGSEGV). I can't promise any of these is your defect; check the release notes between 4.0.8 and current.
What I'm not sure aboutRocky
11/25/2026, 10:57 AM%h vs %I in your STR_TO_DATE format: worth checking against the StarRocks format specifiers, but that would give wrong/NULL values, not a crash.
If it survives step 1 and 3, capture the CN be.out around the failure plus the query profile and open a GitHub issue — a try consume value of 10×2^53 is worth a maintainer's eyes.
References
• administration/configuration/BE_parameters/query_loading.md
• administration/configuration/BE_parameters/stats_storage.md
• sql-reference/System_variable.md
• knowledge/known_issues/query.md (StarRocks knowledge base)
• using_starrocks/Flat_json.md
• administration/configuration/FE_parameters/user_query_loading.mdMohan
11/25/2026, 11:04 AMRocky
11/25/2026, 11:05 AMcbo_json_v2_rewrite is a session-scoped optimizer variable that only controls a rewrite rule in the FE. Turning it off does not disable Flat JSON itself, and it does not change how your data is stored.
What it actually gates vs. what it doesn't
Not affected (storage side, decided at load/compaction time):
• flat_json.enable table property (v4.0+), or BE enable_json_flat (default false pre-4.0, mutable) — this is what makes newly loaded JSON get flattened into subcolumns.
• flat_json.null.factor, flat_json.sparsity.factor, flat_json.column.max.
• enable_compaction_flat_json, enable_compaction_flat_json_mixed_inputs — compaction keeps producing flattened segments.
• Already-flattened data. Per the docs, Flat JSON is "compatible with historical data without needing re-import" — turning a session variable off doesn't rewrite or re-read anything.
Affected (read/plan side, for that session only):
• The rewrite of get_json* into direct Flat JSON subcolumn access. Docs: _"When enabled, JSON functions (such as get_json*) can be rewritten to direct access of Flat JSON subcolumns, enabling predicate pushdown, column pruning, and dictionary optimization."_
• Consequently, cbo_json_v2_dict_opt (low-cardinality dictionary optimization for the extended string subcolumns produced by the rewrite) also has nothing to act on.
So for that session, the 11 get_json_string calls are evaluated against the whole JSON value at execution time instead of being pushed down to subcolumn reads — which is effectively the pre-4.0 read behavior for those expressions. It's the same table, same data, same storage layout; you just lose subcolumn pruning/pushdown on the access path.
Two things that are not all-or-nothing
1. It's per-session. SET cbo_json_v2_rewrite = false; affects only your connection. Other users and other queries keep the optimization. That makes it a clean diagnostic: set it, rerun, compare. No reload, no schema change, no downtime.
2. cbo_prune_json_subfield (default true) is separate. It converts JSON subfield access paths into ColumnAccessPath for the scan operator and is part of flat-JSON pushdown too. So even with the v2 rewrite off, there is still some subfield-level machinery in play — which is exactly why it's worth testing with the v2 rewrite off before concluding anything about where the bad allocation comes from.
Don't disable CBO
cbo_json_v2_rewrite is one rule. Disabling the CBO as a whole (enable_cbo / cbo_enable_* family, join reordering, etc.) is a much bigger hammer and won't target this — the failure looks like a bad size computation in an operator, not a bad plan choice. I'd keep that out of scope.
Caveat
Whether Flat JSON was ever applied to transcripts is a separate question from this variable. If json_response is JSON and the table was created/loaded with flattening, subcolumns exist; otherwise there's nothing to prune and the rewrite was never going to help. And note the docs say historical data won't get Flat JSON optimization until new data is loaded or compaction occurs. So verify with SHOW CREATE TABLE <db>.transcripts (look for flat_json.enable) rather than assuming.
Bottom line: flipping it off is a safe, reversible, session-local test that should cost you JSON read performance for that query and nothing else.
References
• using_starrocks/Flat_json.md
• sql-reference/System_variable.md
• using_starrocks/Cost_based_optimizer.md
• knowledge/known_issues/optimizer.md (StarRocks knowledge base)
• sql-reference/sql-statements/table_bucket_part_index/CREATE_TABLE.mdRocky
11/25/2026, 11:05 AMMohan
11/26/2026, 10:58 AMcbo_json_v2_rewrite , it is failing with same issue. After disabling prune field as well, that specific case is working but queries are taking lot of time, getting timedout.
Are these fixed in the next versions?Rocky
11/26/2026, 10:59 AMcbo_json_v2_rewrite=false but running with cbo_prune_json_subfield=false means:
• The FE-side JSON v2 path rewrite is not your culprit — turning it off changed nothing.
• The failure lives in the BE-side subfield pushdown path (the ColumnAccessPath / PruneSubfield read path that cbo_prune_json_subfield controls).
Since the exact try consume: 90071992547409920 came back unchanged, it's very likely the same code path both times.
Are they fixed in later versions? Honest answer: I can't confirm it for your signature
I found no documented fix whose symptom is a bogus giant allocation in the subfield read path. What exists nearby on the 4.0 line:
Known issue | Fixed in | Relevant to you?
JSON subfield queries crash / wrong results; rewrite registers extended columns on the live table ([PR #78611](https://github.com/StarRocks/starrocks/pull/78611)) | 4.0.17, 4.1.7 | Partly — but you already fail with the rewrite off, so this FE-side fix probably isn't the whole story
Case-only subfield collisions make the scan emit a duplicate access path → mismatched chunk row counts → SIGSEGV ([#76594](https://github.com/StarRocks/starrocks/pull/76594), [#76593](https://github.com/StarRocks/starrocks/pull/76593)) | 4.0.14, 4.1.4/4.1.6 | Worth ruling out — see below
JSON reads return NULL then SIGSEGV when cached pointers survive reallocation ([#66957](https://github.com/StarRocks/starrocks/pull/66957)) | 4.0.4 | No — you're on 4.0.8
get_json_bool on non-boolean data segfaults ([#63054](https://github.com/StarRocks/starrocks/pull/63054)) | 4.0.0 | No
The case-collision bug is the one worth a look, because its mechanism — a duplicated access path producing a chunk whose columns have wildly mismatched sizes — is exactly the shape that could produce a meaningless allocation size. But your path names don't collide by case, so I don't think it's your trigger. I'm flagging the mechanism, not claiming a match.
There is also a subfield-pruning correctness issue I'd be careful about: with cbo_prune_json_subfield=false you're on a supported workaround path (the docs give it for the j->'$'-returns-NULL issue, #80772, fixed 4.1.7 / merged-but-unreleased on 4.0). Sanity-check that your "working" results are actually correct, not just non-failing.
Why it's now slow — this is expected, not a second bug
The docs are explicit for `cbo_prune_json_subfield`: _"Enabling cbo_prune_json_subfield without backend support for flat json may degrade performance; disable it if the BE does not support flat JSON path pushdown."_ With it off, subfields aren't pushed into the scan, so BE reads the whole JSON and extracts per row across 120 days of data — 11 get_json_string calls per row, with $.followup_time_readable extracted twice. Timeout is the natural outcome.
Getting the speed back without re-triggering the crash
1. Don't test the two knobs as one block. You tested rewrite=false (fails) and then both off (works). Try cbo_json_v2_rewrite=true + cbo_prune_json_subfield=false — if that also works, you keep the FE-side pushdown and regain some speed. Also try only SET cbo_prune_subfield = false (the general normalization flag the docs say works together with the JSON one) as a narrower knob than disabling JSON pruning entirely. I'm not certain it's sufficient — it's an experiment.
2. Extract each path once. $.followup_time_readable is fetched twice and $.is_voicemail in the WHERE forces a whole-column pass. Push the extraction into a CTE/subquery, compute rn there, and reference each column once — also lets you filter rn = 1 (your current query computes rn and never uses it).Rocky
11/26/2026, 10:59 AMPushdownAccessPaths / AccessPathHits / AccessPathUnhits / JsonFlattern — a big JsonFlattern confirms the on-site extraction is your cost, and AccessPathUnhits tells you which keys were never flattened.
4. Verify Flat JSON is actually on for this table: SHOW CREATE TABLE <db>.transcripts for flat_json.enable, and SELECT flat_json_meta(json_response) FROM <db>.transcripts_META_. If the keys aren't flattened (docs mention enable_lazy_dynamic_flat_json handles misses at calculation time), no pruning setting will help much.
5. Raise the limits while you diagnose: query_timeout and query_mem_limit per session rather than re-running the crashing shape unmodified.
My recommendation
The only route to a supported fix is a patch upgrade — 4.0.17 or later (ideally latest 4.0.x, or 4.1.7+ if you can). Test your original query, unmodified, with both session variables at defaults immediately after upgrading — that's the only way to know whether one of those PRs actually covers your case.
If it still fails on a current patch, open a GitHub issue with the exact try consume value, the query profile, and the CN be.out around the failure. A rejected allocation of exactly 10×2^53 is distinctive enough that a maintainer should recognise the code path immediately — and the community Slack can get eyes on it faster than the issue tracker alone.
I've been wrong once already in this thread (on the large-column-checker default), so treat the "which patch fixes it" part as unverified until you test it.
References
• using_starrocks/Flat_json.md
• knowledge/known_issues/query.md (StarRocks knowledge base)
• administration/configuration/BE_parameters/query_loading.md
• sql-reference/System_variable.md
• knowledge/known_issues/optimizer.md (StarRocks knowledge base)
• sql-reference/sql-functions/json-functions/json-query-and-processing-functions/json_remove.mdMohan
11/27/2026, 11:22 AMRocky
11/27/2026, 11:22 AMcbo_prune_json_subfield=false. That variable only does anything when the scan actually has flattened subcolumns to prune. So the old table does have Flat JSON subcolumns — they're just not consistently usable, and the subfield-pruning path is where the bogus allocation came from.
Most likely explanation (documented facts + my inference)
The documented rules that produce exactly this divergence:
• "Historical data will not automatically apply Flat JSON optimization unless new data is loaded or Compaction occurs."
• "Historical data will coexist with data flattened by Flat JSON."
• json_flat_null_factor (default 0.3) and json_flat_sparsity_factor (default 0.3): a key is not extracted if its NULL share is too high or its presence share is too low.
• A compaction where some inputs are Flat JSON and some are whole JSON is handled by enable_compaction_flat_json_mixed_inputs / enable_compaction_flat_json_partial_paths.
So if transcripts accumulated data over months — keys added later, json_response shapes drifting, some segments written before flattening was on, some keys just under the sparsity threshold — the old table ends up with segments whose subcolumn sets genuinely differ. Those get_json_* paths then resolve inconsistently: hits on some segments, JsonFlattern on-site extraction on others, and mixed extended columns in the access paths. Nothing you change in the session fixes that, because the inconsistency lives in the data.
A freshly rewritten table is written by one writer with one schema in one pass: every key that passes the factors gets flattened identically in every segment. The pruning path becomes trivially satisfiable — and the buggy path never gets exercised. That's why the copy is fast and doesn't crash, even on fewer resources.
I want to be clear: the layout inconsistency part is documented; the "that inconsistency produces a 10×2^53 allocation" part is my inference, not something I found stated.
Why preprod was fine
Most likely one or more of: fewer/smaller partitions in the 120-day window, a table created fresh there (uniform layout from day one), fewer small segments, or Flat JSON simply not enabled — in which case preprod isn't running the same execution path at all and isn't really a control. Worth checking rather than assuming.
Why all CNs restarted — probably a second, separate problem
Two known shared-data/lake compaction defects match "compaction rebuilds and re-flattens whole segments, high memory":
Issue | Status
Compaction of flat JSON inputs derives an empty layout → every input merged back to whole JSON, re-flattened. Log line: Lake Compaction flat json column: [] (PR #80295) | Fixed 4.1.7; merged on 4.0, unreleased
Compaction only flat-reads the first JSON column; later ones buffer whole output segments (PR #81080) | Merged on 4.0/4.1, unreleased
Both raise compaction memory disproportionately on a table with degraded layout — i.e. your old table, not your new one. That's a plausible reason a query against the old table correlated with cluster-wide restarts while the copy doesn't. Still inference; confirm from the CN logs.
How to confirm, cheaply
```sql
-- 1. Which keys are actually flattened, and as what type?
SELECT flat_json_meta(json_response) FROM <db>.transcripts_META_;
SELECT flat_json_meta(json_response) FROM <db>.transcripts_new_META_;
-- (run with LIMIT 1 and compare; also compare against META of individual partitions)
-- 2. Did the table properties change?Rocky
11/27/2026, 11:22 AMtable = 'transcripts';
Then run the query on *both* tables and diff the profile's Flat JSON block:
```yaml
PushdownAccessPaths: N
AccessPathHits: N # which keys hit
AccessPathUnhits: N # which keys missed
JsonFlattern: Nns # on-site extraction cost — expect this to dominate on the old table
A large JsonFlattern plus AccessPathUnhits naming your $.followup_* keys confirms it. Also compare segment/tablet counts and versions per partition (information_schema.tablets), and on a CN check starrocks_be_flat_json_compaction_mixed_inputs_total and flat_json_compaction_streaming_total.
What to do
1. Keep the old table. You now have a reproducible failure case — it's worth more than the workaround. Reproduce with both session variables at defaults and capture the profile + be.out for a GitHub issue.
2. Make the new table an intentional replacement, not an accident. Verify it has flat_json.enable = "true" and sensible flat_json.null.factor / flat_json.sparsity.factor / flat_json.column.max for your actual key distribution — otherwise you've just turned the buggy path off and given up the speedup. Note ALTER TABLE ... SET ("flat_json.enable"="true") is supported on 4.0, but it won't retro-flatten existing segments; only new loads and compactions will.
3. Check whether the old table is salvageable: enable the properties, then let compaction run (or force it) and re-check flat_json_meta. If old segments converge to the new layout, the rewrite may have been unnecessary.
4. Upgrade to 4.0.17+ and retest the original table unmodified. Both compaction fixes are on 4.0 but unreleased, so the next 4.0 patch is the one that would matter.
One caution: since the fresh table works because it avoids the path rather than because anything was repaired, this may come back as the new table ages and its segments begin to diverge. Worth watching AccessPathUnhits / JsonFlattern on it over time.
References
• administration/configuration/BE_parameters/query_loading.md
• using_starrocks/Flat_json.md
• administration/management/monitoring/metric_details/s.md
• knowledge/known_issues/storage.md (StarRocks knowledge base)
• using_starrocks/Cost_based_optimizer.md
• sql-reference/sql-statements/cbo_stats/ANALYZE_TABLE.md