feat: show pg_restore progress in console via pg_stat_progress_copy#256
Open
raymondjacobson wants to merge 1 commit intomainfrom
Open
feat: show pg_restore progress in console via pg_stat_progress_copy#256raymondjacobson wants to merge 1 commit intomainfrom
raymondjacobson wants to merge 1 commit intomainfrom
Conversation
Adds a new "DB Restore" process entry to the console overview that is
visible during state sync database restoration and hidden otherwise.
- New ProcessStateRestore ("restore") process key, cache entry, and
proto field (ProcessInfo.restore = 11)
- restore_progress.go: pollCopyProgress + queryCopyProgress helpers
that query pg_stat_progress_copy every 2s and format output as
"<table> — X.X / Y.Y GB (Z%)"
- RestoreDatabase now updates the restore process metadata through each
phase: restoring schema → truncating → data COPY (live progress) →
converting to LOGGED → building indexes → completed
- Console overview renders the "DB Restore" card only when the restore
process is actively running (hidden when completed)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
restore_progress.gowith two clean helpers:pollCopyProgress(goroutine driver) andqueryCopyProgress(single poll viapg_stat_progress_copy)RestoreDatabasenow emits phase labels through each step — schema restore → truncate → data COPY (with per-table live progress) → converting to LOGGED → building indexes → completedcore_transactions — 14.2 / 18.1 GB (78%)whenbytes_totalis available,core_transactions — 14.2 GBotherwiseHow it works
During the data COPY phase, a background goroutine polls
pg_stat_progress_copyevery 2 seconds and writes the result into therestoreprocess metadata viaRunningProcessWithMetadata. The poller is cancelled as soon aspg_restorereturns.The console card only renders when
ProcessInfo.Restore.State != COMPLETED, so it's invisible during normal operation.Changes
proto/core/v1/types.protorestore = 11field toProcessInfopkg/core/server/restore_progress.gopollCopyProgress+queryCopyProgresspkg/core/server/cache.goProcessStateRestoreconstant,restoreStatecache field, init, switch casepkg/core/server/connect.gorestoreStateinprocessInfopkg/core/server/state_sync.goRestoreDatabasepkg/core/console/views/pages/overview_page.templTest plan
/console/with live table/progress info🤖 Generated with Claude Code