pg_resetwal: add --cluster-state option - Mailing list pgsql-hackers

From shihao zhong
Subject pg_resetwal: add --cluster-state option
Date
Msg-id CAGRkXqRH=xzB7svv-xFRF=6Lexo8tX0T4XX207uPAwuLys-Kcw@mail.gmail.com
Whole thread
Responses Re: pg_resetwal: add --cluster-state option
Re: pg_resetwal: add --cluster-state option
List pgsql-hackers
Hi hackers,

pg_resetwal always marks the cluster as shut down in pg_control.
Michael suggested in [1] an option to store another state, and David
asked for a separate thread [2]. So here it is.

The patch adds --cluster-state. It takes shut-down, which is the
default, shut-down-in-recovery, shutting-down, in-crash-recovery,
in-archive-recovery or in-production. DB_STARTUP is left out because
the server refuses to start with it.

With any state other than shut-down, the next start goes through crash
recovery. There is no WAL to replay, but the other steps still run.

What I can show is unlogged tables. After an immediate stop and
pg_resetwal -f, the server starts as if it was shut down cleanly, and
an unlogged table keeps what was on disk:

    LOG:  database system was shut down at ...
    $ psql -Atc "select count(*) from u"
    1000
With --cluster-state=in-production the table is reset:
    LOG:  database system was not properly shut down; automatic recovery in progress
    LOG:  redo is not required
    $ psql -Atc "select count(*) from u"
    0

That is the only use I have so far. Michael, what did you have in mind
for it?

[1] https://postgr.es/m/ar8mhs05SzC4hjmu@paquier.xyz
[2] https://postgr.es/m/10a44059-c8f8-4bb5-8950-63390eedfaa0@pgbackrest.org

Thanks,
Shihao

Attachment

pgsql-hackers by date:

Previous
From: shihao zhong
Date:
Subject: Re: examine_variable ignored CollateExpr
Next
From: Fujii Masao
Date:
Subject: Re: Stabilize recovery conflict stats checks in 031_recovery_conflict.pl