Repository navigation
fix(state): skip DuckDB import UI after cutover and drop leftover sources - #1191
Conversation
…rces A later beta boot was still starting a history import and showing Preparing FTW even when DuckDB already had sqlite-v1 receipts. After a verified import, Core now reports complete history immediately, drops the leftover SQLite history tables and imported Parquet files, and leaves SQLite for configuration. Failed and interrupted imports keep the original sources. Full backups still write portable SQLite history so restore and older Core can read it. Image-only downgrade stays refused. Fixes #1143 Signed-off-by: Fredrik Ahlgren <[email protected]>
Bugbot couldn't run - usage limit reachedBugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit. A user or team admin can review and increase usage limits in the Cursor dashboard. (requestId: serverGenReqId_8d99f999-def5-4599-9367-09c6f240962a) |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: e95a16106a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| st.StartedAtMS = time.Now().UnixMilli() | ||
| }) | ||
| return m | ||
| return &historyMigration{ctx: ctx, cancel: cancel, done: make(chan struct{}), progress: progress} |
There was a problem hiding this comment.
Initialize the timer for every background migration
When an existing DuckDB already has its SQLite seed but still needs background work—such as resuming an interrupted import or importing a newly discovered Parquet file—migrateSQLiteHistory is skipped, so nothing now initializes StartedAtMS. runHistoryMigration changes the state to running without setting it, and snapshotLocked consequently reports elapsed time as now - 0 (roughly 56 years), which is rendered directly in the migration UI. Initialize the timestamp when the non-idle background migration starts rather than only during SQLite seeding.
Useful? React with 👍 / 👎.
Summary
After a verified DuckDB history import, later boots no longer start an import or show Preparing FTW / Importing older history. Core drops the leftover SQLite history tables and imported Parquet files so DuckDB owns history and SQLite owns configuration.
This is the cutover that was missing on beta-to-beta updates:
OpenWithBackgroundHistoryalways created a migration withhistory_complete=falseand re-hashed every Parquet receipt, so a box that had already finished the first DuckDB hop still showed the import UI for ~30s.sqlite-v1is present, nothing is pending, the DuckDB generation is bound, and every on-disk Parquet file already has a receipt.cold/diagnostics/.Fixes #1143.
Test plan
go test ./internal/state/— including first import, failed import (sources kept), later boot with no incomplete progress, offlineOpenWithLegacyHistoryretire, and portable backup restore after retirego test ./internal/backup/ ./internal/api/go test + vetts_samples/ cold sample Parquet should go away after startUpdate flows
Note
Medium Risk
Irreversible deletion of SQLite history tables and imported Parquet after verified migration; incorrect idle detection could retire sources early or skip needed imports.
Overview
Fixes the post–DuckDB cutover experience on already-migrated boxes:
OpenWithBackgroundHistorynow treats history as idle when SQLite/Parquet import is fully verified (sqlite-v1, no pending imports, bound generation, every cold Parquet file has a receipt). In that case it does not start the background importer or flash incomplete import UI; it reports complete and mayretireLegacyHistorySourceson that boot.Adds
retireLegacyHistorySources: after a verified import, drops leftover SQLite history/sample/energy tables, deletes imported sample Parquet (notcold/diagnostics/), recordshistory_legacy_sources_retired, and stops recreating those tables on laterOpenmigrations. Failed or interrupted imports leave sources untouched.Full backups still materialize portable SQLite history via
ensureSqliteLegacyHistoryinexportHistoryToSQLiteeven when live SQLite no longer holds those tables. Migration progress timing moves so “starting/seed” only appears when table seeding actually runs.Reviewed by Cursor Bugbot for commit e95a161. Bugbot is set up for automated code reviews on this repo. Configure here.