Repository navigation
Description
Proposed consolidated tracking scope: 单值 LIST 分区裁剪与 INSERT panic
These are independent reproductions grouped under one acceptance contract; a common immediate root cause is not assumed. Administrative consolidation does not claim that any defect is fixed. Original report bodies and discussions remain available at the links below.
Included reports
- #25504 — [Bug]: INSERT into LIST COLUMNS partition table panics
Acceptance checklist
- Retain old LIST COLUMNS INSERT as a historical regression; its reported recovery does not prove all paths fixed.
- Cover singleton LIST and LIST COLUMNS point reads and duplicate-check reads, plus multi-value partition controls.
Summary
On current main (workspace at bac18ed24), partition pruning crashes with a nil pointer dereference for any LIST-partitioned table whose partition definitions use a single-value VALUES IN list, whenever the pruner evaluates an equality predicate on the partition column. That includes:
INSERTinto such a table when it has aPRIMARY KEY(the internal duplicate-check read prunes partitions with an equality on the partition column) — plainINSERT ... VALUESandINSERT ... ON DUPLICATE KEY UPDATEboth fail;- an explicit point read
SELECT ... WHERE <partition column> = const.
The failure is a server-side Go panic surfaced to the client as ERROR 20101 (HY000): internal error: panic runtime error: invalid memory address or nil pointer dereference. The statement fails; the CN process survives.
1. Actual Behavior
CREATE TABLE t (id int PRIMARY KEY, v int)
PARTITION BY LIST (id) (PARTITION p0 VALUES IN (1), PARTITION p1 VALUES IN (2));
INSERT INTO t VALUES (1,1);
-- ERROR 20101 (HY000) at line: internal error: panic runtime error: invalid memory
-- address or nil pointer dereference: ... listFilterExprNormalized ...
SELECT * FROM t WHERE id = 1;
-- ERROR 20101 (HY000): same panicReproduced 3/3 via mysql CLI and again after a server restart; also observed through mo-tester BVT-style execution (insert and insert ... on duplicate key update both panic).
2. Expected Behavior
- The row is inserted into partition p0 / the point read returns the row.
- The same DDL with multi-value lists (
VALUES IN (1,2)) works today and yields exactly the expected rows; the insertion and the point read on the single-value DDL must behave identically. - MySQL 8.0 semantics:
PARTITION BY LIST (id)withVALUES IN (1)is a legal definition; the statement succeeds.
3. Steps to Reproduce
Minimal SQL (deterministic):
DROP DATABASE IF EXISTS loom_repro;
CREATE DATABASE loom_repro;
USE loom_repro;
CREATE TABLE t (id int PRIMARY KEY, v int)
PARTITION BY LIST (id) (PARTITION p0 VALUES IN (1), PARTITION p1 VALUES IN (2));
INSERT INTO t VALUES (1,1); -- panic (ERROR 20101)
SELECT * FROM t WHERE id = 1; -- panic (ERROR 20101)
-- controls on the same server, same session:
CREATE TABLE t2 (id int PRIMARY KEY, v int)
PARTITION BY LIST (id) (PARTITION p0 VALUES IN (1,2), PARTITION p1 VALUES IN (3,4));
INSERT INTO t2 VALUES (1,1); -- OK
SELECT count(*) FROM t2; -- OK
CREATE TABLE t3 (id int, v int)
PARTITION BY LIST (id) (PARTITION p0 VALUES IN (1), PARTITION p1 VALUES IN (2));
INSERT INTO t3 VALUES (1,1); -- OK (no PK -> no dedup read, no pruning)
SELECT count(*) FROM t; -- OK (no filter -> no list-expr evaluation)Also reproduces with:
- partition expressions:
PARTITION BY LIST (id+id),LIST (id*id),LIST ((id+id)*id)(fresh ODKU tables, INSERT panic); PARTITION BY LIST COLUMNS(region)(varchar, composite PK): INSERT works today, but point readSELECT ... WHERE region = 'east'panics.
Deterministic Go reproducer at package level (added in workspace, not committed): pkg/partitionprune/loom_test_list_single_value_test.go builds the metadata exactly as the DDL plan binder emits it for a single-value VALUES IN and calls partitionprune.Filter:
$ CGO_CFLAGS="#cgo includes" go test ./pkg/partitionprune/ -run TestLoomListSingleValuePartitionDefDoesNotPanic -count=1
--- FAIL: TestLoomListSingleValuePartitionDefDoesNotPanic (0.00s)
loom_test_list_single_value_test.go:63: partitionprune.Filter panicked on single-value LIST partition
definition: runtime error: invalid memory address or nil pointer dereference
4. Additional information
Panic stack (identical for INSERT and SELECT):
github.com/matrixorigin/matrixone/pkg/container/vector.(*Vector).Length vector.go:321
github.com/matrixorigin/matrixone/pkg/partitionprune.listFilterExprNormalized filter.go:742
github.com/matrixorigin/matrixone/pkg/partitionprune.listFilterExpr filter.go:658
github.com/matrixorigin/matrixone/pkg/partitionprune.listFilter filter.go:567
github.com/matrixorigin/matrixone/pkg/partitionprune.Filter filter.go:55
... disttae.getPruneTablesFunc / filterNilPrunedRelations / combinedTxnTable.Ranges ...
... compile.expandRanges -> buildScanParallelRun (insert dedup read and point select both reach this)
Root cause chain:
pkg/sql/plan/partition_binder.go:293re-synthesizes eachPARTITION ... VALUES IN (v1,...)astree.NewComparisonExpr(tree.IN, column, tree.NewTuple(valuesIn.ValueList)).tree.NewTupledoes not setTuple.Partition(seepkg/sql/parsers/tree/expr.go,NewTuple), so the bound expression goes down the ordinary IN path inpkg/sql/plan/base_binder.go.- In
base_binder.gothe in-list expansion collapses a single-element list to a plain=comparison (exactSingleComparison, expansion atbase_binder.go:7465). The resulting catalogPartitionDef.Deffor such a partition isF("=", [col, const]), notF("in", [col, Expr_List]). - At runtime
partitionprune.listFilterExprNormalized(pkg/partitionprune/filter.go:742, loop overmetadata.Partitions) callsextractListValues(t.Expr)(filter.go:596), which returns(nil, nil)for the equality shape, thenconstructVectorFromList(proc, nil)(filter.go:606) returns(nil, nil)for an empty list, and the caller unconditionally runsbat.SetRowCount(bat.Vecs[0].Length())on the nil vector → panic.
The defect is long-latent: constructVectorFromList has returned (nil, nil) for unrecognized shapes since the list pruner was introduced, and the single-element IN collapse also applies to partition defs; no BVT inserts into or point-reads single-value LIST partitions with a PK (ddl/partition.sql uses only multi-value lists and LOAD DATA), so it escaped e2e coverage.
Relationship to existing issue #25504 ([Bug]: INSERT into LIST COLUMNS partition table panics, still open): the July repro on LIST COLUMNS VALUES IN ('east') no longer panics on current main — the INSERT path was fixed — but the same underlying pruner defect remains reachable today through (a) SELECT ... WHERE <partition column> = const on LIST COLUMNS single-value tables and (b) all single-value LIST(<expression>) DDL including INSERT via the PK duplicate-check read. This report covers the residual defect with the mechanism above; #25504 can serve as the tracking issue if maintainers prefer.
Suggested fix (either side suffices, both is best):
- prune side: in
listFilterExprNormalized, treatconstructVectorFromList's(nil, nil)as "cannot prune this partition safely" — returncanPrune=false(fall back to all partitions) instead of dereferencing the nil vector; alternatively haveconstructVectorFromListreturn an error; - plan side: preserve the partition-list semantics by marking the tuple (
Tuple.Partition = true→partition_inopcode keeps the in-list node even for one element), or emitF("in", [col, Expr_List])for partition defs.
Environment: workspace at commit bac18ed24 ("fix(vector): preserve constant selection grouping metadata (#30119)"), detached main lineage; single-binary mo-service -launch with 1 CN + 1 TN + 1 LOG service, default pessimistic/RC mode; macOS 15.5, arm64; mysql client 9.x. The panic is not load-, data-, or timing-dependent: every attempt failed identically.
Found by Loom bug hunt (module: custom-0342c965ce; tests: unit, white-box, end-to-end)
Activity
zuyu commentedon Dec 3, 2026
Additional case not covered above: a mixed LIST definition, where one partition has a multi-value list and another a single-value list. One single-value partition is enough to make every pruned read on the table panic, including point reads and inserts whose value belongs to the multi-value partition.
Reproduced on main
66002aa3fd:Controls on the same server:
All five failures panic at
pkg/partitionprune/filter.go:744(listFilterExprNormalized), the same site as this report. Suggest adding the mixed definition, including an equality on a value of the multi-value partition, to the acceptance checklist.