Re: BUG #18006: recovery_target_action=shutdown triggers automatic recovery on next startup (beyond point in time) - Mailing list pgsql-bugs

From Kyotaro Horiguchi
Subject Re: BUG #18006: recovery_target_action=shutdown triggers automatic recovery on next startup (beyond point in time)
Date
Msg-id 20230630.115027.1504907442857233086.horikyota.ntt@gmail.com
Whole thread Raw
In response to BUG #18006: recovery_target_action=shutdown triggers automatic recovery on next startup (beyond point in time)  (PG Bug reporting form <noreply@postgresql.org>)
List pgsql-bugs
This is not a bug.

At Thu, 29 Jun 2023 08:04:21 +0000, PG Bug reporting form <noreply@postgresql.org> wrote in 
> When I run everything with `recovery_target_action=shutdown` the server
> while in recovery mode reaches the target and successfully shuts down.
> I then manually remove the `recovery.signal` file as mentioned in the docs
> of `recovery_target_action`
> https://www.postgresql.org/docs/current/runtime-config-wal.html#RUNTIME-CONFIG-WAL-ARCHIVE-RECOVERY
> , so that the server does a normal startup next run.
> But as you can see in the logs below the server logs `database system was
> not properly shut down; automatic recovery in progress` and it continues to
> recover everything.

This is pretty standard when a stopped standby is launched as a
primary.

In that sense, a shutdown during recovery mode is always an "improper"
shutdown, because it doesn't run a shutdown-checkpoint. However, that
behavior is quite normal for a standby, so you don't see the message
when starting as a standby.

> I would expect it to stay at the recovery target and not replay any further
> wal files.

That's not really the case. Recovery always starts from the last
retartpoint LSN. That LSN is recorded in the control file and you can
check it using pg_controldata.

> To me that feels like a bug, or undesired behavior, or is there anything
> else needed to be done manually that `pg_wal_replay_resume()` does when
> everything halts on pause (maybe docs are not comprehensive)?

pg_wal_replay_resume() just continues a paused reocvery while the
server is running. Once the whole server goes down, it requires a
recovery unless it is known to have been shut down cleanly as a
non-standby.

The idea behind the "shutdown" mode of recoery_target_action is to
prepare a standby that needs the minimum WALs at the next startup. In
reality, recovery always starts from the last restart point. It is
normal behavior of the recovery process, too. And it is written in the
documentation.

https://www.postgresql.org/docs/15/runtime-config-wal.html

> The shutdown setting is useful to have the instance ready at the exact
> replay point desired. The instance will still be able to replay more
> WAL records (and in fact will have to replay WAL records since the
> last checkpoint next time it is started).

regards.

-- 
Kyotaro Horiguchi
NTT Open Source Software Center



pgsql-bugs by date:

Previous
From: "Tristan Partin"
Date:
Subject: Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG
Next
From: Alexander Lakhin
Date:
Subject: Re: BUG #17997: Assert failed in validatePartitionedIndex() when attaching partition index to child of valid index