Re: Fix FATAL error when using recovery_target = 'immediate' on cleanly shut down clusters

From: Srinath Reddy Sadipiralla <srinath2133(at)gmail(dot)com>
To: surya poondla <suryapoondla4(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-25 16:58:31
Message-ID: CAFC+b6pdiHpnQMudT8piwi9ATK3=m33gMarpQvS4MZJDSZ17sg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Surya,

On Tue, Nov 24, 2026 at 3:02 AM surya poondla <suryapoondla4(at)gmail(dot)com>
wrote:

>
> 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.
>

TYSM!!! for reviewing and testing :)

>
> 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.
>

i think in this thread [0] already Zsolt handled these cases in his v3
patchset,
which I noticed later, please have a look there.

>
> 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.
>

agreed.

[0] -
https://www.postgresql.org/message-id/flat/19897-60cf65e39604f958%40postgresql.org

--
Thanks :)
Srinath Reddy Sadipiralla
EDB: https://www.enterprisedb.com/

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Nathan Bossart 2026-11-25 17:01:40 Re: PANIC at shutdown when a reload changes full_page_writes
Previous Message Andreas Karlsson 2026-11-25 16:53:53 Re: Small cleanup of leftover pre-1.1.0 OpenSSL code