| From: | surya poondla <suryapoondla4(at)gmail(dot)com> |
|---|---|
| To: | Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com> |
| Cc: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Subject: | Re: Fix FATAL error when using recovery_target = 'immediate' on cleanly shut down clusters |
| Date: | 2026-11-23 21:31:53 |
| Message-ID: | CAOVWO5pyOBcLhNVR7OZ0tzpWWq=Wfzzao+gCVtU5d0qCgUxFQQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Srinath,
> While i working on this reported bug [0], i observed this;
> currently, if you restore a backup where no WAL follows the
> shutdown checkpoint, PerformWalRecovery() realizes there is
> nothing to replay and takes the "redo is not required" path.
> Because this path bypasses the main WAL replay loop, neither
> recoveryStopsBefore() nor recoveryStopsAfter() gets called,
> then if the user requested an 'immediate' recovery target, the
> server exits with:
> FATAL: recovery ended before configured recovery target was reached.
>
>
Thank you for reporting the issue and the patch.
I reproduced this on master with a cold copy of a cleanly stopped cluster,
recovery.signal and recovery_target = 'immediate':
LOG: consistent recovery state reached at 0/020000B0
LOG: redo is not required
FATAL: recovery ended before configured recovery target was reached
I reproduced this on master with a cold copy of a cleanly stopped
cluster, recovery.signal and recovery_target = 'immediate':
LOG: consistent recovery state reached at 0/020000B0
LOG: redo is not required
FATAL: recovery ended before configured recovery target was reached
v1 fixes it. I tested each recovery_target_action on the no-redo path,
pause (and pg_wal_replay_resume() then promotes), promote,
shutdown (recovery.signal is kept), and pause with hot_standby = off
(turned into shutdown, as on the normal replay path).
Things that should not change didn't i.e with no recovery target the server
still
promotes, an unreachable recovery_target_name still fails with the
same FATAL, and 'immediate' on an online base backup still stops at
the backup end. The new test in 003_recovery_targets.pl passes with the
patch and fails without it.
A few comments:
1. The patch also fixes a standby case that the commit message does
not mention. A server started with standby.signal and recovery_target =
'immediate' that never receives any WAL waits for
it; if it is promoted, it takes the same "redo is not required" path.
On master that fails with the same FATAL, and the pg_promote() caller
loses its connection when the server shuts down:
LOG: received promote request
LOG: redo is not required
FATAL: recovery ended before configured recovery target was reached
With v1 it promotes. It would be worth mentioning in the commit message
and covering in the test.
2. The test only covers the default action, pause. The attached test-only
diff (applies on top of v1) adds promote, shutdown and the
standby case above; feel free to take what you like. I named it .txt so
cfbot does not pick it up.
3. The FATAL check goes back to dc788668bb2 in PG13, and the same
code is in all supported branches (I only tested master). On
REL_19_STABLE the xlogrecovery.c part of v1 applies cleanly and only
the test code conflicts and on 15-18 the code also conflicts, on
pg_fallthrough. I feel this can be back-ported.
Regards,
Surya Poondla
>
| Attachment | Content-Type | Size |
|---|---|---|
| v1-immediate-no-redo-extra-tests.txt | text/plain | 3.5 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Zsolt Parragi | 2026-11-23 21:59:58 | Re: [PATCH v1] Fix for Bug#19724 - ALTER TYPE ... ALTER ATTRIBUTE triggers internal error for base type of domain with check |
| Previous Message | Tomas Vondra | 2026-11-23 20:46:14 | Re: Compression of bigger WAL records |