Skip to content

[Bug]: PITR RESTORE DATABASE loses secondary indexes that existed at the restore timestamp (index DDL not rolled back) — snapshot restore handles the same case correctly #30614

Closed as duplicate

Description

@Ariznawlll

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

Activity

  1. added
    kind/bug
    on Oct 19, 2026
  2. added this to the MO-202610 milestone on Oct 19, 2026
  3. XuPeng-SH commented on Oct 22, 2026

    @XuPeng-SH
    Contributor

    Consolidated into #30615. The secondary-index-at-target-time case is retained as a separate acceptance test in the canonical PITR restore issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions