fix(postgresql): make PITR restore_command replayable and timestamp comparison numeric#3072
Draft
weicao wants to merge 1 commit into
Draft
fix(postgresql): make PITR restore_command replayable and timestamp comparison numeric#3072weicao wants to merge 1 commit into
weicao wants to merge 1 commit into
Conversation
…omparison numeric
- restore_command moved WAL segments out of the staging dir as
recovery consumed them ('mv ${PITR_DIR}/%f %p'); a mid-recovery
restart (pod eviction, OOM — routine on Kubernetes) re-requests
earlier segments through restore_command and they are gone, so the
restore can never complete. The .history branch already used cp,
conceding the hazard. Now cp for all files, matching PostgreSQL's
own documented restore_command examples. Disk note: fetch-wal-log
stages the entire window in PITR_DIR up front, so the peak is
already paid; cp adds only transient duplication in pg_wal bounded
by recovery checkpoint recycling.
- fetch-wal-log's stop condition used [[ $timestamp > $restore_time ]]
— lexicographic. Both operands are epoch seconds (currently equal
width, so accidentally correct); now -gt.
- new pitr_restore_spec.sh (3 examples): runs the same concatenation
the ActionSet builds (set -e + common + fetch + restore) and pins
the cp restore_command + staging/idempotent-retry behavior; the
timestamp case uses a 9-digit vs 10-digit epoch pair that fails
under lexicographic comparison and passes under -gt.
Fixes #3071
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3072 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 144 145 +1
Lines 23013 23080 +67
=====================================
- Misses 23013 23080 +67 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
Deep-review finding 三.20 (issue #3071):
mv: PostgreSQL re-requests earlier WAL segments through restore_command whenever recovery restarts mid-way (pod eviction, OOM, node restart — routine on Kubernetes). Withmv, those segments are gone from the staging dir and the restore can never complete — the PITR attempt is burned. The.historybranch already usedcp, conceding the point.[[ $ts > $rt ]]): both operands are epoch seconds of currently-equal width, so it is accidentally correct today — a latent trap.Changes
restore_command='cp ${PITR_DIR}/%f %p'for all files (PostgreSQL's own documented example shape). Disk boundary: fetch-wal-log stages the whole window up front, so the peak is already paid; cp adds only transient pg_wal duplication bounded by recovery checkpoint recycling.-gtfor the epoch comparison.Evidence boundary
Static + concatenated-form shellspec (suite 23/23 locally, shellcheck clean at CI severity). The mid-recovery-restart replay scenario is not runtime-reproduced; it will be covered in the draft-batch integration round (T3 PITR window) and/or the #postgresql team's kubeblocks-tests negative-path cases (task #29 alignment).
Opened as draft per the batch process (tests pass → ready). Will be added to integration/pg-review-batch.
🤖 Generated with Claude Code