From: Laurenz Albe <laurenz.albe@cybertec.at>
To: Zwettler Markus (OIZ) <Markus.Zwettler@zuerich.ch>
To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>
Cc: Daisuke Ikeda <dai.ikd123@gmail.com>
Subject: Re: AW: Re: PostgreSQL container crash trouble.
Date: Thu, 11 Mar 2021 14:22:55 +0100
Message-ID: <a7d475b4c66decbbb33178b5310d113874d736cd.camel@cybertec.at> (raw)
In-Reply-To: <07b9abcdad504a179325ec6431327d8e@zuerich.ch>
References: <07b9abcdad504a179325ec6431327d8e@zuerich.ch>
Markus, you should know about not top-posting on these lists.
On Thu, 2021-03-11 at 10:52 +0000, Zwettler Markus (OIZ) wrote:
> > On Mon, 2021-03-08 at 22:30 +0900, Daisuke Ikeda wrote:
> > > I'm running PostgreSQL (enabled timescaledb extension) in the following environment.
> > > And I had db pod crashed error several times irregularly.
> > >
> > > I want to know the cause of this fail.
> > >
> > > 1) PostgreSQL crash and cannot start Pod..
> > >
> > > [20] LOG: invalid primary checkpoint record [20] PANIC: could not locate a valid checkpoint record
> > > [1] LOG: startup process (PID 20) was terminated by signal 6: Aborted
> > > [1] LOG: aborting startup due to startup process failure
> >
> > WAL does not contain the checkpoint from before the crash.
> >
> > > I thought it might be WAL trouble and tried to check with pg_controldata and pg_waldump.
> > > ---
> > > $ pg_controldata <PostgreSQL data dir> [...]
> > > Latest checkpoint location: 15/8FB002C0
> > > Latest checkpoint's REDO location: 15/8FAF3018
> > > Latest checkpoint's REDO WAL file: 00000001000000150000008F
> > > [...]
> > >
> > > I checked the latest checkpoint's REDO WAL file.
> > >
> > > But the content is all zero data. I checked this situation with "od" command.
> > >
> > > ---
> > > $ od -N 40 -A d -v pg_wal/00000001000000150000008F
> > > 0000000 000000 000000 000000 000000 000000 000000 000000 000000
> > > 0000016 000000 000000 000000 000000 000000 000000 000000 000000
> > > 0000032 000000 000000 000000 000000
> > > 0000040
> > > ---
> >
> > Looks like modifications to this file were lost.
> >
> > Somehow you lost the data for a WAL segment, and you cannot recover.
> >
> > Of course, if you have a backup, you know what to do.
>
> You said use your backup.
>
> Wouldn't it be enough to start instance crash recovery just before the corrupted wal in that case?
>
> recovery_target_lsn = <<lsn for 00000001000000150000008F>>
> recovery_target_inclusive = off
>
> No need for a backup. Correct?
No, not correct.
You could perhaps locate the checkpoint before that in the WAL with
"pg_waldump" and manufacture an appropriate "backup_label" to start
recovery from there.
But by the time you reach 00000001000000150000008F, your recovery would
stop, and the database would believe it was recovered.
However, there might be some data modifications in the data files from
a later point in time, which amounts to data corruption.
WAL is called WAL because you always have to write to WAL first,
only then to the data files. You cannot have a change to the data
files that is not WAL logged.
Yours,
Laurenz Albe
--
Cybertec | https://www.cybertec-postgresql.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: laurenz.albe@cybertec.at, Markus.Zwettler@zuerich.ch, dai.ikd123@gmail.com
Subject: Re: PostgreSQL container crash trouble.
In-Reply-To: <a7d475b4c66decbbb33178b5310d113874d736cd.camel@cybertec.at>
References: <07b9abcdad504a179325ec6431327d8e@zuerich.ch> <a7d475b4c66decbbb33178b5310d113874d736cd.camel@cybertec.at>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox