Repository navigation
Description
Is there an existing issue for the same bug?
- I have checked the existing issues. ([Subtask]: Validate on-demand View metadata across DDL, security, restore, and version boundaries #29440 is a general view-metadata refactoring subtask, not this concrete restore defect.)
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
- Fresh standalone instance;
create pitr if not exists p1 for account range 3 'h'; - Per round: create database + table + view; wait 5s; T=now(); drop view; sleep 30s;
restore database <db> from pitr p1 '<T>'; - 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
- BVT: pitr/ has no view×PITR scenario; only snapshot-side view restore is covered.
- Combined with [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/[Bug]: Restore paths must preserve target-time data and foreign-key integrity #30615, a database restored via PITR loses indexes, FK semantics, and (intermittently) views — while only publications are reconstructed. The consolidated fix suggestion (column-name-based historical catalog restore helper) in [Bug]: PITR RESTORE DATABASE silently returns wrong data when the restore-point baseline is not yet materialized — first-executed restores degrade to current/partial state with no warning (order-dependent) #30616's comment applies here too.
Activity
XuPeng-SH commentedon Oct 22, 2026
Consolidated into #30615. The view-at-target-time case is retained as a separate acceptance test in the canonical PITR restore issue.