| From: | Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org> |
| Cc: | Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com> |
| Subject: | Fix FATAL error when using recovery_target = 'immediate' on cleanly shut down clusters |
| Date: | 2026-11-18 18:18:41 |
| Message-ID: | CAFC+b6q2rubdCpku9cH_D5k3cMP8m1TPmCkLRnqMibfBr16SSA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi,
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.
This happens even though the cluster is already in a consistent
state, it means the 'immediate' target was already reached before
replay even started.
The attached patch updates the "redo is not required" path to
recognize that the server is already consistent and recovery can
stop if the target is immediate.
To implement this cleanly, I could not just skip the error, as the
server must still do the recovery_target_action. To avoid duplicating
that logic, I moved the target action handling code out of the main loop
and into a new helper function called PerformRecoveryTargetAction(),
this also adds a TAP test; thoughts?
[0] -
https://www.postgresql.org/message-id/flat/19897-60cf65e39604f958%40postgresql.org
--
Thanks :)
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/
| Attachment | Content-Type | Size |
|---|---|---|
| V1-0001-Treat-an-immediate-recovery-target-as-reached-whe.patch | application/octet-stream | 6.4 KB |
| From | Date | Subject | |
|---|---|---|---|
| Previous Message | Tom Lane | 2026-11-18 17:46:58 | Re: [PATCH] Normalize numeric/bigint scientific notation after rounding |