[Bug]: COPY ALTER ADD COLUMN FIRST makes MASTER-indexed rows invisible
I maintainer di solito rispondono entro 1 giorno
@XuPeng-SH ci sta già lavorando.
Dal 26/11/2026.
Valutazione
Questa issue non è ancora stata valutata.
Descrizione
Description
Tested on MatrixOne main c0cef5c9cce2164fedd201c188bfffe4d2d09a96 (version() = 8.0.30-MatrixOne-v1.3.0, git_version() = c0cef5c), single CN.
After COPY ALTER inserts a column before existing columns, an unaffected MASTER index makes existing rows disappear from filtered queries. The base rows and hidden MASTER entries still exist, but the MASTER index join returns no matching rows.
Minimal reproduction
CREATE TABLE m(
a VARCHAR(30),
b VARCHAR(30),
INDEX mi USING MASTER(a)
);
INSERT INTO m VALUES('x','payload');
SELECT a,b FROM m WHERE a='x';
-- Before ALTER: ('x','payload')
ALTER TABLE m ADD COLUMN lead INT DEFAULT 7 FIRST,ALGORITHM=COPY;
SELECT a,b FROM m WHERE a='x';
-- Actual: empty set
-- Expected: ('x','payload')
SELECT COUNT(*) FROM m WHERE a='x';
-- Actual: 0
-- Expected: 1
SELECT a,b FROM m IGNORE INDEX(mi) WHERE a='x';
-- Positive control: ('x','payload')
SELECT COUNT(*) FROM m IGNORE INDEX(mi) WHERE a='x';
-- Positive control: 1
The failure persists on a fresh connection. Two independent fresh-database reproductions produced identical results.
Positive controls and scope
- An ordinary
KEY ri(a)remains correct after the sameADD COLUMN ... FIRST. - A MASTER index remains correct when the new column is appended at the end instead of inserted before existing columns.
IGNORE INDEX(mi)returns the original row, proving that the base row was not lost.- Rebuilding the affected index with
ALTER TABLE m ALGORITHM=COPY,MODIFY COLUMN a VARCHAR(40)makes the query return the row again. - Single-column and composite MASTER indexes, with and without an explicit primary key, reproduce the problem. Duplicate keys and duplicate complete rows were also covered.
- The hidden MASTER entries remain present after ALTER; this is not physical loss of hidden-index rows.
Root cause
MASTER lookup keys include the source column's physical Seqnum:
pkg/sql/plan/apply_indices_master.goconstructs lookup prefixes usingserial_full(getColSeqFromColDef(...), value).pkg/sql/plan/apply_indices.go:getColSeqFromColDefreturnsColDef.Seqnum.pkg/sql/compile/alter.go:cloneUnaffectedIndexesclones an unaffected index's old hidden entries without rewriting those keys.
ADD COLUMN ... FIRST changes the existing columns' physical sequence numbers in the replacement table. New queries therefore generate prefixes using the new sequence numbers, while the cloned MASTER entries still contain the old sequence numbers. Appending a column does not renumber existing columns, and MODIFY on an indexed column rebuilds the entries, explaining both positive controls.
Expected behavior
COPY ALTER must preserve MASTER-index query results for every existing row. If column renumbering requires MASTER entries to be rewritten, the unaffected-index clone path must rewrite them or rebuild the index; it must not publish an index that silently returns false-empty results.
Duplicate check
Open and closed searches covered USING MASTER with ALTER TABLE, MASTER with ADD COLUMN or ALGORITHM=COPY, serial_full, Seqnum, COPY ALTER FIRST, and MASTER wrong results. No matching issue was found.
This differs from #32245, which tracks missing ordinary/unique hidden-index entries: here the MASTER entries remain complete but their Seqnum key labels no longer match the replacement schema. It also differs from #32056 (stale composite-PK references in ordinary indexes), #33108 (FK-action index maintenance), and #25586 (MASTER LIMIT/OFFSET paging).
- Lingua principale
- Go
- Stelle
- 1.9k
- Fork
- 312
- Merge medio
- 22h 59m
- PR unite (30g)
- 736
Preparare l'ambiente
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di matrixorigin/matrixone
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 84/100
matrixorigin/matrixone#33363 ·
I maintainer di solito rispondono entro 1 giorno
-
kind/bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
matrixorigin/matrixone#33362 ·
I maintainer di solito rispondono entro 1 giorno
-
SLEEP rejects NULL and negative durations that MySQL acceptsForse già presa @XuPeng-SH l’ha presa 7 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
matrixorigin/matrixone#32653 ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: TestChangeWatchProxy loses its first tenant connection during PingContext in Ubuntu CIForse già presa @XuPeng-SH l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33371 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
-
[Bug]: TestDaemonClaimSQLRoundTrip exhausts its shared deadline during the stale claim update in Ubuntu CIForse già presa @XuPeng-SH l’ha presa oggi. Apertakind/bug needs-triage
matrixorigin/matrixone#33370 · 1 assegnatario ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di matrixorigin/matrixone
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
pg-sharding/spqr#3314 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
slavakurilyak/awesome-ai-agents#1051 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 73/100
google-gemini/gemini-api-cli#247 ·
I maintainer di solito rispondono entro 1 giorno