Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues.
Branch Name
main
Commit ID
b24d1b3 (2026-10-16)
Other Environment Information
- Hardware: macOS arm64 (Apple Silicon)
- Topology: single-node standalone
- OS: macOS
Actual Behavior
PITR RESTORE DATABASE ... FROM PITR does not roll back secondary-index DDL metadata: indexes that existed at the restore timestamp are lost, and indexes created after it can survive. Data rows restore correctly — only the index layer is wrong.
Reproduced 3/3 rounds, each on a clean database:
create database kidx;
create table kidx.t (id int primary key, k int);
insert into kidx.t values (1,7);
create index ik_a on kidx.t(k);
-- T_MARK: timestamp NOW (ik_a exists at this point)
-- sleep 30s (beyond PITR granularity), then:
drop index ik_a on kidx.t;
create index ik_b on kidx.t(k);
restore database kidx from pitr p1 '<T_MARK>';
show index from kidx.t;
-- Round 1: ik_a GONE, ik_b still present (a post-restore-point index!)
-- Rounds 2,3: ik_a GONE, ik_b also absent (table left with no secondary index at all)Control experiment — the equivalent SNAPSHOT restore handles this correctly:
create snapshot snp_i for database kidx2; -- sk_a exists at snapshot time
drop index sk_a on kidx2.t;
create index sk_b on kidx2.t(k);
restore database kidx2 {snapshot="snp_i"};
show index from kidx2.t; -- sk_a correctly restored, sk_b correctly gone ✓So the two restore paths disagree again: snapshot restore rolls index metadata back to the chosen point; PITR restore rebuilds the table data but silently drops the index DDL that belonged to the restore point (and in round 1 even leaked the newer index definition).
Data content itself is consistent after the PITR restore (index-scan and full-scan queries agreed in earlier trials when the surviving index matched), so the defect is specific to index/catalog metadata handling in the PITR database-restore path.
Expected Behavior
After RESTORE DATABASE ... FROM PITR p '<T>', the table's index set must match the state at <T>: pre-existing indexes restored and functional (EXPLAIN uses them), indexes created after <T> absent — exactly what the snapshot path already implements.
Root cause direction
The PITR database-restore path (pkg/frontend/pitr.go) rebuilds the database by replaying CREATE TABLE from the historical catalog via {MO_TS} reads (restoreTable/getCreateTableSqlWithTs family), but nothing recreates the mo_indexes / secondary-index metadata rows for the historical point the way the snapshot path does. Secondary indexes in MatrixOne live as separate catalog entries / hidden tables; dropping the db and replaying the table DDL alone loses index definitions that were part of the table's definition at <T>.
Impact
A user restoring to recover from bad data loses the performance indexes their workload depended on (silent regression to full scans), or worse, gets a stale/leaked index definition from a later state — with no error or warning either way.
Additional information
- Same "restore-paths-disagree" family as [Bug]: RESTORE DATABASE {snapshot=...} silently deletes publications targeting the restored database and never recreates them — subscribers break permanently #30610 (snapshot restore drops publications that PITR restore reconstructs) — here it is inverted: snapshot handles indexes, PITR does not.
- Closest existing issues ([Bug]: FULLTEXT INDEX secondary table lost on concurrent snapshot restore #23861 fulltext secondary table on concurrent snapshot restore, [Bug]: same-statement DROP/ADD of an indexed column silently removes its index #30270 same-statement DROP/ADD column) are different scenarios; no existing issue covers "PITR database restore loses secondary indexes".
Activity
XuPeng-SH commentedon Oct 22, 2026
Consolidated into #30615. The secondary-index-at-target-time case is retained as a separate acceptance test in the canonical PITR restore issue.