Skip to content

[Bug]: ALTER ADD PARTITION breaks indexes added after CREATE TABLE #33393

In review

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Searched open and closed issues for ADD PARTITION with index out of range, getPartitionIndexesTables, post-CREATE secondary/UNIQUE indexes, and the FULLTEXT/IVFFLAT/MASTER variants. #28311 reports cannot write data to partition primary table for a different FULLTEXT partition INSERT scenario. Closed #32211 covers CREATE INDEX metadata not being published (Error 1176), and closed #32881 covers IVF/HNSW parent metadata and REINDEX. None covers this ALTER-add-index followed by ADD PARTITION sequence and its getPartitionIndexesTables panic.

Branch Name

main

Commit ID

c0cef5c

Other Environment Information

  • Hardware parameters: single-CN local deployment
  • OS type: macOS
  • Others: reproduced in two fresh databases for each index variant; git_version() = c0cef5c

Actual Behavior

If a secondary index is added with ALTER after a partitioned table is created, the index works initially. After ALTER TABLE ... ADD PARTITION, INSERT and queries that use the index fail with Error 20101 and an internal bounds panic:

internal error: panic runtime error: index out of range [0] with length 0
...
github.com/matrixorigin/matrixone/pkg/vm/engine/disttae.(*txnTableDelegate).getPartitionIndexesTables

This is not limited to irregular indexes. The same sequence fails for:

  • ordinary secondary and UNIQUE indexes, including FORCE INDEX reads;
  • FULLTEXT and MATCH ... AGAINST;
  • IVFFLAT and ANN ordering;
  • MASTER indexes and FORCE INDEX reads.

The failed INSERT does not add the new row, and the pre-ALTER base row remains readable. The pre-ADD-PARTITION index queries succeed as positive controls.

Expected Behavior

Adding a partition must preserve all indexes in the table's current definition, including indexes added after the initial CREATE TABLE. DML and indexed reads should continue to work without an internal panic.

Steps to Reproduce

The ordinary/UNIQUE case is sufficient to reproduce the problem:

DROP DATABASE IF EXISTS repro_partition_indexes;
CREATE DATABASE repro_partition_indexes;
USE repro_partition_indexes;

CREATE TABLE t(id INT PRIMARY KEY, u INT, v INT)
PARTITION BY RANGE COLUMNS(id)(
  PARTITION p0 VALUES LESS THAN(10)
);
INSERT INTO t VALUES(1,10,100);

-- Add the indexes after the partitioned CREATE TABLE.
ALTER TABLE t ADD UNIQUE KEY uk_u(u);
ALTER TABLE t ADD KEY idx_v(v);

-- Both positive controls return id=1.
SELECT id FROM t FORCE INDEX(uk_u) WHERE u=10;
SELECT id FROM t FORCE INDEX(idx_v) WHERE v=100;

ALTER TABLE t ADD PARTITION(
  PARTITION p1 VALUES LESS THAN(20)
);

-- Error 20101: index out of range, getPartitionIndexesTables.
INSERT INTO t VALUES(11,11,110);
SELECT id FROM t FORCE INDEX(uk_u) WHERE u=10;
SELECT id FROM t FORCE INDEX(idx_v) WHERE v=110;

-- The failed INSERT was not applied; the old row remains.
SELECT * FROM t;

The additional variants use the same ordering—create partitioned table, ALTER-add index, verify an indexed read, ADD PARTITION—and replace the index/query with:

-- FULLTEXT (with experimental_fulltext_index=1)
ALTER TABLE t ADD FULLTEXT INDEX ft(body);
SELECT id FROM t WHERE MATCH(body) AGAINST('hello');

-- IVFFLAT (with experimental_ivf_index=1)
ALTER TABLE t ADD INDEX ivf USING IVFFLAT(v) LISTS=1 OP_TYPE 'vector_l2_ops';
SELECT id FROM t ORDER BY l2_distance(v,'[1,0,0]') LIMIT 1;

-- MASTER
ALTER TABLE t ADD INDEX ms USING MASTER(v);
SELECT id FROM t FORCE INDEX(ms) WHERE v='one';

All variants produce the same internal panic after ADD PARTITION.

Additional Information

Static inspection points to partition index-table metadata: getPartitionIndexesTables indexes into a per-partition relation list that is empty for the newly added physical partition. The new partition is derived from stale table CREATE SQL that does not contain indexes introduced by later ALTER statements, so its hidden index tables/index metadata are not constructed consistently with the current table definition.

Activity

  1. added this to the MO-202611 milestone on Nov 27, 2026
  2. added
    kind/bug
    area/partition
    on Nov 27, 2026
  3. added theissue type on Nov 27, 2026
  4. removed
    area/partition
    on Nov 27, 2026
  5. added a commit that references this issue on Dec 1, 2026
    16b9b15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugneeds-triage

Type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions