Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
- Related false-rejection fixes: fix(hashbuild): avoid false spill budget rejection for reused tail batches #26178, fix(hashbuild): avoid runtime filter budget false rejection #26231 — this case still rejects after those.
- Not the same as shuffle panic [Bug]: dispatch.shuffleToAllFunc panic: index out of range on multi-CTE LEFT JOIN + RANK (jinpan invoice_acdoca_link) #25930 / window split [Bug]: Window operator fails when agg Flush returns split vectors (>8192 rows): "does not support sending split result of window function" #25813 / hashjoin nil [Bug]: hashjoin panic: nil pointer in (*container).finalize (join.go:716) on multi-CTE LEFT JOIN query #25802.
Branch Name
main
Commit ID
2e6877406157470e453245ef287d35ff81fc0c84
Image: registry.cn-shanghai.aliyuncs.com/matrixorigin/matrixone:nightly-2e687740
Other Environment Information
- Hardware: single-node MO (docker, host port 16001), rootless docker on Linux
- Host memory: ~251 GiB; container Memory limit unset (0)
- OS: Linux
- Dataset: jinpan_001 (local LOAD DATA INFILE)
- Suite: cases/jinpan_001/join (1000 SQLs), template srm_contract_attach
- processLimitationSize default: 42949672960 (40 GiB) from pkg/config/configuration.go
Actual Behavior
All executed variants of template srm_contract_attach fail immediately (cost_ms=0) with:
(20101) internal error: hash build budget admission rejected
Operator diagnostic (CN log hashbuild/types.go summary), repeated almost identically every hit:
hash_build budget admission rejected:
requested = 551368048640 (~513 GiB / ~551 GB)
used ≈ 1589595280 (~1.48 GiB)
cap = 42949672960 (40 GiB = default processLimitationSize)
extra_stats:
QueryHashBudgetCapBytes = 42949672960
QueryHashBudgetPeakBytes ≈ 6–7e9
QueryHashBudgetRejects = 1
QueryHashBudgetReserves ≈ 570
Client sees only the short error string; detailed requested/used/cap is in CN operator diagnostics.
Regression evidence
| Build | Template hits | Result |
|---|---|---|
nightly-826a3e3d (before hash-build budget hard path in this form) |
31/31 | success, cost_ms ≈ 0.7–1.3s, returns rows |
nightly-2e687740 (current) |
13/13 so far (of 31) | failed, cost_ms=0, same admission error |
So this is a behavior regression: same SQL + same data used to finish in ~1s.
Expected Behavior
- Query succeeds (as on
826a3e3d), returning up toLIMITrows; or - If build memory is truly tight, HashBuild should spill (code already has shuffle + admission-reject →
startSpill()paths) instead of failing with a ~551GB one-shot reserve that cannot be realistic for this query; and - Client / log error should remain actionable (
requested/used/capis good — keep it).
Raising processLimitationSize alone is not a valid fix: even 100GiB cap cannot admit a 551GB request. The 40GiB figure is the default process limit narrowing queryCap, not proof the query needs >40GiB.
Steps to Reproduce
- Load jinpan_001 (tables below non-empty).
- Execute the SQL (case
j_batch_001/@q0009_srm_contract_attach). - Observe
(20101) hash build budget admission rejectedwith diagnostics as above.
Table sizes (this env)
| Table | Rows |
|---|---|
dwd_dcp.dwd_srm_pur_headers_all |
~514,007 (~52,597 after filter) |
dwd_dcp.dwd_srm_con_contract_headers |
~541,469 |
dwd_dcp.dwd_srm_fnd_atm_attachment_multi |
~1,161,861 |
dwd_dcp.dwd_srm_fnd_atm_attachment |
~1,152,847 |
Repro SQL
SELECT * FROM (
SELECT DISTINCT
TRIM(h.display_po_number) AS ebeln,
'采购合同' AS doctype,
TRIM(a.file_name) AS file_name,
CAST(a.attachment_id AS CHAR) AS attachment_id,
TRIM(m.file_token) AS file_token,
CAST(ch.contract_header_id AS CHAR) AS owner_id,
MD5(CONCAT('SRM|采购合同|', CAST(a.attachment_id AS CHAR), '|', COALESCE(m.file_token, ''))) AS attachment_key
FROM dwd_dcp.dwd_srm_pur_headers_all h
JOIN dwd_dcp.dwd_srm_con_contract_headers ch
ON ch.contract_number = CONCAT(CAST(h.segment1 AS CHAR), '-', CAST(h.revision_num AS CHAR))
JOIN dwd_dcp.dwd_srm_fnd_atm_attachment_multi m
ON m.table_pk_value = CAST(ch.contract_header_id AS CHAR)
AND m.table_name = CASE WHEN ch.contract_type_code = 'ATM_CON' THEN 'CON_CONTRACT_HEADERS' ELSE 'CON_CONTRACT_DOC' END
JOIN dwd_dcp.dwd_srm_fnd_atm_attachment a ON a.attachment_id = m.attachment_id
WHERE h.type_lookup_desc = '运输费用采购订单'
AND h.display_po_number IS NOT NULL AND h.display_po_number <> ''
) w
WHERE 1 = 1
LIMIT 500;Other failing variants differ only by doctype string / LIMIT (100–2000); all hit the same admission error.
EXPLAIN (plan shape)
AP QUERY PLAN ON ONE CN
Project
-> Aggregate (DISTINCT) Limit 500
-> Join INNER -- attachment_multi ⋈ contract (CAST / CASE expr conds)
-> Join INNER shuffle:range(attachment_id) -- attachment ⋈ attachment_multi
-> Join INNER -- contract ⋈ headers (CONCAT expr cond)
Expression join keys (CONCAT / CAST) likely contribute to bad build-size estimation.
Additional information
Why this looks like an engine bug (not “need more RAM”)
- Same query succeeded in <2s on older nightly with same dataset.
- One-shot
requested≈513GiBwhile peak used under budget was only ~6–7GiB and final result is tiny (LIMIT 500). - Default
processLimitationSize=40GiB(10<<32inpkg/config/configuration.go) explains cap=40GiB, but does not explain requesting 551GB. - HashBuild already documents spill-on-admission-reject for shuffle; this case still fails the pipeline instead of spilling successfully.
Activity
Ariznawlll commentedon Aug 23, 2026
测试版本
maindc403fbac6a09c77ac93bb023fe83056308a038b1 CN + 1 TN + 1 Log,使用默认查询内存限制;会话设置max_dop=8、join_spill_mem=0,未通过提高processLimitationSize绕过问题原问题验证
按 Issue 原始数据规模和相关字段类型构造 4 张表:
segment1/display_po_number/type_lookup_desc使用TEXTcontract_type_code/contract_number使用TEXTtable_pk_value/table_name/file_token使用TEXTfile_name使用TEXT执行
ANALYZE TABLE后,使用原问题中的CONCAT + CAST、CAST、CASE三层表达式 JOIN、DISTINCT和LIMIT 500执行EXPLAIN ANALYZE与结果查询。完整用例由 3 个独立测试进程执行,3/3 通过。每轮内部连续查询 3 次,9/9 均返回
500行;未再出现原问题的20101 internal error: hash build budget admission rejected。另外在本地 MySQL 8.3.0 中装载完全相同的 4 张表、行数、字段类型和 JOIN SQL,生成确定性 Oracle;再在 MatrixOne 上执行同一摘要查询。两边结果逐项一致:总结果
110692、去重 attachment key110692、owner 范围/求和10 / 514000 / 26731571780、attachment 范围/求和1 / 1152838 / 62069757082,排序后的前 10 行与 MD5 key 也一致。Happy Path 覆盖
EXPLAIN ANALYZE通过,计划包含三层Join Type: INNER,表达式 JOIN 路径被实际执行。SELECT 1返回1,连接仍可正常使用。LIMIT 500的行数。Unhappy Path 覆盖
TEXT表达式键下未触发 551 GB 错误估算或 admission rejection。0。白盒验证
不适用。本问题可通过公开 SQL 接口和原始规模数据完整触发,验收采用黑盒 big-data 查询;HashBuild 强制 spill 已由现有
35_multikey_hashbuild_spill_100M.sql独立覆盖,本用例不通过人为降低阈值替代原 admission 场景。回归测试
query_tests_1y串行矩阵:mo-nightly-regression#1455main_only,不会在尚未包含修复的 4.2-dev 上运行,也没有新增独立 Job。测试证据
dc403fba...对比:四表行数、完整结果摘要、排序样本和 MD5 key 全部一致;上述完整摘要已固化进 Golden,并在更新后再次 3/3 通过。MERGEABLE,测试代码、Golden 和矩阵接入可在上述 PR 中核对。测试结论
测试通过。