Skip to content

[Bug]: PITR RESTORE DATABASE intermittently (2/3) loses views defined at the restore timestamp — tables and data restore fine; snapshot restore handles views correctly (5th metadata-type asymmetry) #30649

Closed as duplicate

Description

@Ariznawlll

Is there an existing issue for the same bug?

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

RESTORE DATABASE ... FROM PITR intermittently (2/3 rounds) fails to restore views that existed at the restore timestamp — the restored database comes back with its tables and data but the view definitions are silently gone.

Reproduction protocol (each round on a fresh database, 5s settle before taking T):

create database vpx;
create table vpx.t (id int primary key);
create view vpx.v as select id from vpx.t;
-- T = now()
drop view vpx.v;
-- sleep 30s
restore database vpx from pitr p1 '<T>';

select count(*) from information_schema.tables
  where table_schema='vpx' and table_name='v';

Results across 3 identical rounds: 0 (view lost), 1 (correct), 0 (view lost) — while the underlying table t and its data restore correctly every time. In an earlier run the companion view created after T also failed to disappear properly: the restored DB had neither the pre-T view nor was cleaned of post-T ones — the view layer simply did not participate in the restore.

Control experiment — the equivalent SNAPSHOT restore handles views correctly: same drop-view-then-restore flow with restore database vps {snapshot="sv"} → view restored (1/1).

This is the fifth member of the restore-path metadata asymmetry family:

Metadata type snapshot restore PITR restore Issue
secondary index ✓ ✗ lost #30614
foreign key ✓ ✗ lost + enforcement gone #30615
view ✓ ✗ lost (intermittent 2/3) this issue
publication ✗ dropped ✓ (crashes on layout mismatch) #30610/#30607
CDC task (external) ✗ killed via generation guard n/a #30645

The intermittency matches the baseline-materialization race documented in #30616 — the view-definition replay appears to race with the PITR sampling window, producing inconsistent restore output for identical inputs.

Expected Behavior

After restoring to timestamp T, the view set must match T exactly: pre-T views present and queryable (with their dependency on restored base tables intact), post-T views absent — as the snapshot path already does deterministically.

Steps to Reproduce

  1. Fresh standalone instance; create pitr if not exists p1 for account range 3 'h';
  2. Per round: create database + table + view; wait 5s; T=now(); drop view; sleep 30s; restore database <db> from pitr p1 '<T>';
  3. Query information_schema for the view — 2/3 rounds show it missing while table data restored fine.

Root cause direction

The PITR database restore (pitr.go) replays table DDL from the historical catalog but view replay (like index/FK replay, restoreViewsFromTS exists only in the snapshot path — snapshot_restore_with_ts.go) has no PITR counterpart. The intermittent behavior suggests whatever partial view handling exists rides on timing relative to the PITR background sampling, consistent with the #30616 race.

Additional information

Activity

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

    @XuPeng-SH
    Contributor

    Consolidated into #30615. The view-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