feat: track restore stage in _pgro.restore_info#25
Conversation
Adds `stage` and `last_transition_time` columns to `_pgro.restore_info`. Init script sets stage to `restored` when a post-restore reindex is pending, or `ready` otherwise. The background reindex block transitions to `reindexing` before starting and `ready` after completion. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
|
🦸 Review Hero Summary Below consensus threshold (2 unique issues not confirmed by majority)
Local fix prompt (copy to your coding agent)Fix these issues identified on the pull request. One commit per issue fixed.
|
| restored_at = now(); | ||
| restored_at = now(), | ||
| stage = EXCLUDED.stage, | ||
| last_transition_time = now(); |
There was a problem hiding this comment.
[Bugs & Correctness] suggestion
The ON CONFLICT clause always resets last_transition_time = now() regardless of whether stage actually changed. If the init container re-runs on a pod restart after a restore has already completed (e.g. the same stage value is upserted), last_transition_time gets bumped to the restart time, making it look like a stage transition just occurred. Fix: last_transition_time = CASE WHEN _pgro.restore_info.stage IS DISTINCT FROM EXCLUDED.stage THEN now() ELSE _pgro.restore_info.last_transition_time END
| PG_MAJOR=$(cat /pgdata/pgdata/PG_VERSION) | ||
| ( | ||
| while ! pg_isready -q -U postgres -d postgres; do sleep 2; done | ||
| psql -U postgres -d postgres -c "UPDATE _pgro.restore_info SET stage = 'reindexing', last_transition_time = now() WHERE id = 1;" |
There was a problem hiding this comment.
[Bugs & Correctness] suggestion
The 'reindexing' and 'ready' UPDATE statements in the postgres container silently affect 0 rows if the _pgro.restore_info row is missing (e.g. the init container's psql heredoc failed partway through — psql does not abort on statement error by default). Stage tracking is then permanently lost with no indication of failure. Consider adding || echo 'WARNING: stage update affected 0 rows' after each UPDATE, or asserting row count via a DO block.
|
🦸 Review Hero Summary Below consensus threshold (2 unique issues not confirmed by majority)
Local fix prompt (copy to your coding agent)Fix these issues identified on the pull request. One commit per issue fixed.
|
Adds
stageandlast_transition_timecolumns to_pgro.restore_info.Init script sets stage torestoredwhen a post-restore reindex ispending, orreadyotherwise. The background reindex block transitionstoreindexingbefore starting andreadyafter completion.🦸 Review Hero