Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
v4.2.5
Commit ID
Other Environment Information
SELECT VERSION(): 8.0.30-MatrixOne-v4.2.5
Application: InvenTree 1.5.7
InvenTree commit: 2ca0d0e55b08e138342b20fccfa8307fad25a02c
Django: 5.2.16
Deployment: isolated local environment, using the MySQL protocol.Actual Behavior
After completing InvenTree’s native database migrations, creating a part and a stock item through its authenticated native API succeeds.
Reading the part subsequently returns HTTP 500. Isolating the native Django ORM annotations shows that the in_stock correlated aggregate returns SQL error 20101, containing this recovered Go panic:
internal error: panic runtime error: index out of range [10] with length 9:
runtime.panicBounds64
/opt/hostedtoolcache/go/1.26.4/x64/src/runtime/panic.go:236
runtime.panicBounds
/opt/hostedtoolcache/go/1.26.4/x64/src/runtime/asm_amd64.s:2129
github.com/matrixorigin/matrixone/pkg/sql/colexec.(*ColumnExpressionExecutor).Eval
/home/runner/work/matrixone/matrixone/pkg/sql/colexec/evalExpression.go:1194
github.com/matrixorigin/matrixone/pkg/sql/colexec.(*FunctionExpressionExecutor).Eval
The error returned over the MySQL protocol truncates the remaining stack trace.
Expected Behavior
Expected behavior
For the described fixture, the query should return:
id | in_stock
40002 | 23.12500
This expected result follows from the fixture’s stock quantity and the query predicates; a separate MySQL comparison has not yet been performed.
The query should not produce an executor panic.
Impact and observations
- Blocks the native InvenTree part detail workflow; part GET and PATCH requests returned HTTP 500.
- An independently isolated external_stock annotation also returned the same bounds-panic signature.
- Other queries continued to execute after the error. A MatrixOne process crash was not observed.
- The separate 20102 non-equality correlated aggregate rejection and 1064 column-remapping error are additional observations and are not included as this panic’s root cause.
- The confirmed panic location is ColumnExpressionExecutor.Eval. The underlying planner or executor defect, and whether the outer category join is necessary to trigger it, remain unconfirmed.
Steps to Reproduce
Reproduction context
This was observed against the migrated InvenTree schema, with:
- Part ID: 40002
- Stock item belonging to this part
- Stock quantity: 23.12500
- Stock status: 10
- is_building = 0
- belongs_to_id, consumed_by_id, customer_id and sales_order_id all NULL
The complete failing statement below was extracted from the native Django ORM query, with its bound parameters substituted.
A standalone minimal DDL reproducer has not yet been verified. The statement requires the corresponding InvenTree tables and fixture data.
Complete failing SQL
SELECT
`part_part`.`id` AS `id`,
COALESCE(
(
SELECT SUM(U0.`quantity`) AS `aggregation`
FROM `stock_stockitem` U0
WHERE (
U0.`belongs_to_id` IS NULL
AND U0.`consumed_by_id` IS NULL
AND U0.`customer_id` IS NULL
AND U0.`is_building` = 0
AND U0.`quantity` > 0
AND U0.`sales_order_id` IS NULL
AND U0.`status` IN (10, 50, 55, 85)
AND U0.`part_id` = (`part_part`.`id`)
)
GROUP BY U0.`part_id`
ORDER BY NULL
),
0
) AS `in_stock`
FROM `part_part`
LEFT OUTER JOIN `part_partcategory`
ON (`part_part`.`category_id` = `part_partcategory`.`id`)
WHERE `part_part`.`id` = 40002
ORDER BY
`part_part`.`tree_id` ASC,
`part_part`.`lft` ASC
LIMIT 1;Additional information
No response
Activity
XuPeng-SH commentedon Oct 13, 2026
Verification on current main
3e50e1b32dVerified source revision:
3e50e1b32d8da61bbbf70c89989fb08b671809de. Upstream main was checked again after execution and still resolved to this SHA.Environment: Linux amd64, Go 1.27.1, fresh matching CPU CGo libraries, the repository's canonical embedded one-CN SQL fixture, GOMAXPROCS=2, and fresh owned schemas. This used the actual MySQL frontend and engine. Embedded tests leave release/version strings at development defaults; source/build provenance establishes the tested revision, rather than a release
VERSION()string. All test schemas and owned temporary resources were cleaned up.Result: original correlated SQL and native schema shape pass
Executed the complete SQL from this issue, retaining the four native tables' column order, types, and indexes from the earlier captured SHOW CREATE fixture. Restored all 11 native FK edges whose referenced tables are inside that four-table fixture; FKs to unrelated application tables remain outside the fixture.
The original query returned:
No
ColumnExpressionExecutor.Evalbounds panic occurred. Additional checks passed:external_stockannotation returned its expected zero for the retained non-external location.1.87500produced25.00000.23.12500.Disposition: the original SQL and tested native database shape no longer reproduce the panic on main. This is stronger than the earlier reduced-column fixture, but does not claim a complete migrated InvenTree schema or authenticated GET/PATCH workflow was run. The full application workflow was excluded following the requester's clarification. No new production patch is justified by this reproducer.
Ariznawlll commentedon Oct 13, 2026
测试版本
main21f19ae06305ca2acd253d15123f851899d6b6a13e50e1b32d8da61bbbf70c89989fb08b671809de对保留原生列顺序、类型、索引及 11 条夹具内外键的四表 SQL 验证原问题验证
在当前 main 上执行 issue 中的
part_part/part_partcategory/stock_stockitem关联库存聚合 SQL,保留COALESCE、关联SUM、GROUP BY、ORDER BY NULL、LEFT JOIN 和外层排序/限制。目标 part40002连续 3 轮返回in_stock=23.12500,无ColumnExpressionExecutor.Eval越界 panic。此前更接近 InvenTree 原生四表结构的原 SQL 也返回相同值,见下方已有验证记录。Happy Path 覆盖
(40002, 23.12500);每轮源表 3 行、数量总和129.12500不变。0.00000;增加一条合格库存后返回25.00000。23.12500;外层分类为空时 LEFT JOIN 仍保留目标 part 和正确库存总和。Unhappy Path 覆盖
(40002, 23.12500),源数据未被破坏。白盒验证
本问题以实际 SQL 执行器行为验收;本次没有新增内部故障注入或
-race,它们无法替代原 SQL 的结果与无 panic 检查。回归测试
script/14_issue_regression/issue_29926_inventree_correlated_sum.py及对应.out。在当前 main 的独立实例上运行./motr --repeat 3 14_issue_regression.issue_29926_inventree_correlated_sum,3/3 success、0 failed、0 skipped;脚本内部的原查询也每次重复 3 轮。与 golden 对照 3/3 一致,用例数据库已清理。测试证据
total=3 success=3 failed=0 skipped=0。测试结论
测试通过。