Re: [BUG] non archived WAL removed during production crash recovery

From: Kyotaro Horiguchi <horikyota(dot)ntt(at)gmail(dot)com>
To: jgdr(at)dalibo(dot)com
Cc: masao(dot)fujii(at)oss(dot)nttdata(dot)com, pgsql-bugs(at)lists(dot)postgresql(dot)org, michael(at)paquier(dot)xyz
Subject: Re: [BUG] non archived WAL removed during production crash recovery
Date: 2020-04-08 08:39:09
Message-ID: 20200408.173909.874800874546158298.horikyota.ntt@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

At Tue, 7 Apr 2020 17:17:36 +0200, Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com> wrote in
> > +/* Recovery state */
> > +typedef enum RecoveryState
> > +{
> > + NOT_IN_RECOVERY = 0,
> > + IN_CRASH_RECOVERY,
> > + IN_ARCHIVE_RECOVERY
> > +} RecoveryState;

I'm not sure the complexity is required here. Are we asuume that
archive_mode can be changed before restarting?

At Thu, 2 Apr 2020 15:49:15 +0200, Jehan-Guillaume de Rorthais <jgdr(at)dalibo(dot)com> wrote in
> > Ok, so our *current* consensus seems the followings. Right?
> >
> > - If archive_mode=off, any WAL files with .ready files are removed in
> > crash recovery, archive recoery and standby mode.
>
> yes

If archive_mode = off no WAL files are marked as ".ready".

> > - If archive_mode=on, WAL files with .ready files are removed only in
> > standby mode. In crash recovery and archive recovery cases, they keep
> > remaining and would be archived after recovery finishes (i.e., during
> > normal processing).
>
> yes
>
> > - If archive_mode=always, in crash recovery, archive recovery and
> > standby mode, WAL files with .ready files are archived if WAL archiver
> > is running.
>
> yes

So if we assume archive_mode won't be changed after a crash before
restarting, if archive_mode = on on a standy, WAL files are not marked
as ".ready". If it is "always", WAL files that are to be archived are
marked as ".ready". Finally, the condition reduces to:

If archiver is running, archive ".ready" files. Otherwise ignore
".ready" and just remove WAL files after use.
>
> > That is, WAL files with .ready files are removed when either
> > archive_mode!=always in standby mode or archive_mode=off.
>
> sounds fine to me.

That situation implies that archive_mode has been changed. Can we
guarantee the completeness of the archive in the case?

regards.

--
Kyotaro Horiguchi
NTT Open Source Software Center

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-04-08 08:39:39 BUG #16350: pgcenter expects postgresql12-libs on postgresql 11
Previous Message Dmitry Dolgov 2020-04-08 08:20:32 Re: BUG #16325: Assert failure on partitioning by int for a text value with a collation

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Kapila 2020-04-08 09:05:44 Re: pg_stat_statements issue with parallel maintenance (Was Re: WAL usage calculation patch)
Previous Message Fujii Masao 2020-04-08 08:37:27 Re: Planning counters in pg_stat_statements (using pgss_store)