Re: [BUG] non archived WAL removed during production crash recovery
Kyotaro Horiguchi <horikyota.ntt@gmail.com>
From: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
To: jgdr@dalibo.com
Cc: masao.fujii@oss.nttdata.com, pgsql-bugs@lists.postgresql.org,
michael@paquier.xyz
Date: 2020-04-08T08:39:09Z
Lists: pgsql-bugs, pgsql-hackers
At Tue, 7 Apr 2020 17:17:36 +0200, Jehan-Guillaume de Rorthais <jgdr@dalibo.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@dalibo.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
Commits
-
Fix interpolation in test name.
- e16e9204692c 11.10 landed
- af2d09fa1c28 12.5 landed
- 6fb1c5b52826 13.0 landed
- 47a3a1c3d498 14.0 landed
-
Add more TAP coverage for archive status with crash recovery of standbys
- ebf6de869276 13.0 landed
-
Fix handling of WAL segments ready to be archived during crash recovery
- 9eff11653962 9.5.22 landed
- c2d8ae0dfe84 9.6.18 landed
- 02657c42199c 10.13 landed
- 2d24ca00b750 11.8 landed
- 22db5269bfa1 12.3 landed
- 4e87c4836ab9 13.0 landed
-
Fix WAL recycling on standbys depending on archive_mode
- 78ea8b5daab9 12.0 cited