From: Alban Hertroys <haramrae@gmail.com>
To: Jan Wieck <jan@wi3ck.info>
Cc: Stephen Frost <sfrost@snowman.net>
Cc: Edson Carlos Ericksson Richter <richter@simkorp.com.br>
Cc: pgsql-general@lists.postgresql.org
Subject: Re: Does PostgreSQL check database integrity at startup?
Date: Sat, 30 Dec 2017 12:25:08 +0100
Message-ID: <1B534695-9219-4555-B31E-92A73D390621@gmail.com> (raw)
In-Reply-To: <CAGBW59eqjmsymYJUFO6q0Yya3G2AonSi-h0vUiUCYKYUsLLM_w@mail.gmail.com>
References: <20171227213314.GY4628@tamriel.snowman.net>
<20171227215204.nucxo7b2ssmyznip@alvherre.pgsql>
<20171228121651.GZ4628@tamriel.snowman.net>
<42cda197-fead-a7e5-a7e2-750d98bc4eb2@simkorp.com.br>
<743808611.5608368.1514484408822@mail.yahoo.com>
<20171228182636.GG4628@tamriel.snowman.net>
<CAGBW59fasv0KxRg6YTfQM7+zzmJ6jnwBvDGEiNi0aJH9HyqCzA@mail.gmail.com>
<48a4bcfa-6b85-81ca-9b59-9e47af8fa5af@simkorp.com.br>
<20171230011315.GC2416@tamriel.snowman.net>
<CAGBW59eqjmsymYJUFO6q0Yya3G2AonSi-h0vUiUCYKYUsLLM_w@mail.gmail.com>
> On 30 Dec 2017, at 6:09, Jan Wieck <jan@wi3ck.info> wrote:
>
> This whole discussion left out the critical point of
>
> how on earth did that file end up having zero bytes?
>
> There is the possibility that this is due to a bug in PostgreSQL. But over the 20+ years I've been using and hacking it, that has never happened.
>
> OP never told us what type of OS, hardware and specifically storage subsystem that "slave" was running on. Filesystems zapping files to zero after a catastrophic IO failure (no longer throwing them into lost+found) isn't unheard of.
If this is indeed a case of a corrupt database, then it's possible that we're looking at a system that claims to have the disk cache flushed when it hasn't yet done that.
It gets even more fun if there are multiple table-spaces in use with different behaviour in "whatever is causing this" (fsync, file system zappery, etc.); the WAL log can get out of synch with the table files in that case. The WAL would reflect a situation where more has been flushed to the respective files than is actually the case - data got lost.
But of course it's also entirely possible that these empty files are not in fact a problem, as suggested up-thread.
No reason to panic - yet.
In fact, I don't see it mentioned explicitly anywhere, but are we actually looking at a problem?
The standby server started up just fine, from what I'm reading. Is there any evidence of corruption?
So far, the database has been labeled corrupt by Edson because a base file was 0 bytes, but that's apparently not a definitive indication of corruption.
What would be definitive is if querying certain relations causes errors or does give results that were never in that database. I do think that those 0 byte files are a good starting point, by querying the relations that those belong to (if any). Otherwise we may be searching for a needle in a haystack that doesn't necessarily contain one.
I do realise that not finding any evidence of corruption does not necessarily mean there is none.
I'm not convinced by the argument that a CRC check of a 0 byte file on a standby would not detect corruption. At the least, the CRC would be different or we would be left with a CRC on the master that we can't match any CRC's on the slave to if the file is larger on the master.
If CRC's can be relied on to detect corruption (which they were designed to do), then that answers Edson's question.
Alban Hertroys
--
If you can't see the forest for the trees,
cut the trees and you'll find there is no forest.
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: haramrae@gmail.com, jan@wi3ck.info, sfrost@snowman.net, richter@simkorp.com.br
Subject: Re: Does PostgreSQL check database integrity at startup?
In-Reply-To: <1B534695-9219-4555-B31E-92A73D390621@gmail.com>
References: <20171227213314.GY4628@tamriel.snowman.net> <20171227215204.nucxo7b2ssmyznip@alvherre.pgsql> <20171228121651.GZ4628@tamriel.snowman.net> <42cda197-fead-a7e5-a7e2-750d98bc4eb2@simkorp.com.br> <743808611.5608368.1514484408822@mail.yahoo.com> <20171228182636.GG4628@tamriel.snowman.net> <CAGBW59fasv0KxRg6YTfQM7+zzmJ6jnwBvDGEiNi0aJH9HyqCzA@mail.gmail.com> <48a4bcfa-6b85-81ca-9b59-9e47af8fa5af@simkorp.com.br> <20171230011315.GC2416@tamriel.snowman.net> <CAGBW59eqjmsymYJUFO6q0Yya3G2AonSi-h0vUiUCYKYUsLLM_w@mail.gmail.com> <1B534695-9219-4555-B31E-92A73D390621@gmail.com>
* 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