Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUX7O-00057F-8n for pgsql-general@arkaria.postgresql.org; Thu, 28 Dec 2017 12:17:02 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUX7M-0003Yn-VZ for pgsql-general@arkaria.postgresql.org; Thu, 28 Dec 2017 12:17:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eUX7M-0003Ye-OO for pgsql-general@lists.postgresql.org; Thu, 28 Dec 2017 12:17:00 +0000 Received: from tamriel.snowman.net ([96.255.250.162]) by magus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eUX7F-00007d-FQ for pgsql-general@lists.postgresql.org; Thu, 28 Dec 2017 12:16:59 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 08A695F795; Thu, 28 Dec 2017 07:16:51 -0500 (EST) Date: Thu, 28 Dec 2017 07:16:51 -0500 From: Stephen Frost To: Alvaro Herrera Cc: Edson Carlos Ericksson Richter , pgsql-general@lists.postgresql.org Subject: Re: Does PostgreSQL check database integrity at startup? Message-ID: <20171228121651.GZ4628@tamriel.snowman.net> References: <20171227213314.GY4628@tamriel.snowman.net> <20171227215204.nucxo7b2ssmyznip@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="IgjJ2PKSh+KhnqU7" Content-Disposition: inline In-Reply-To: <20171227215204.nucxo7b2ssmyznip@alvherre.pgsql> User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --IgjJ2PKSh+KhnqU7 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Alvaro, * Alvaro Herrera (alvherre@alvh.no-ip.org) wrote: > For context: this was first reported in the Barman forum here: > https://groups.google.com/forum/#!msg/pgbarman/3aXWpaKWRFI/weUIZxspDAAJ > They are using Barman for the backups. Ahhhh, I see. I wasn't aware of that history. > Stephen Frost wrote: >=20 > > > But at some point in time, slave became corrupt (one of the base > > > files are zero size where it should be 16Mb in size), and IMHO a > > > "red alert" should arise - Slave server shall not even startup at > > > all. > >=20 > > How do you know it should be 16Mb in size...? That sounds like you're > > describing a WAL file, but you should be archiving your WAL files during > > a backup, not just using whatever is in pg_xlog/pg_wal.. >=20 > It's not a WAL file -- it's a file backing a table. Interesting. > > > Since backups are taken from slave server, all backups are also corru= pt. > >=20 > > If you aren't following the appropriate process to perform a backup > > then, yes, you're going to end up with corrupt and useless/bad backups. >=20 > A few guys went over the backup-taking protocol upthread already. >=20 > But anyway the backup tool is a moot point. The problem doesn't > originate in the backup -- it originates in the standby, from where the > backup is taken. The file can be seen as size 0 in the standby. > Edson's question is: why wasn't the problem detected in the standby? > It seems a valid question to me, to which we currently we don't have any > good answer. The last message on that thread seems pretty clear to me- the comment is "I think this is a failure in standby build." It's not clear what that failure was but I agree it doesn't appear related to the backup tool (the comment there is "I'm using rsync"), or, really, PostgreSQL at all (a failure during the build of the replica isn't something we're necessairly going to pick up on..). As discussed on this thread, zero-byte files are entirely valid to appear in the PostgreSQL data directory. To try and dig into what happened, I'd probably look at what forks there are of that relation, the entry in pg_class, and try to figure out how it is that replication isn't complaining when the file on the primary appeared to be modified well after the last modify timestamp on the replica. If it's possible to replica this into a test environment, maybe even do a no-op update of a row of that table and see what happens with replication. One thing I wonder is if this table used to be unlogged and it was later turned into a logged table but something didn't quite happen correctly with that. I'd also suggest looking for other file size mismatches between the primary and the replica. Thanks! Stephen --IgjJ2PKSh+KhnqU7 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaROCzAAoJEO1sijiDR2RVdXQP/RV1FUSEFfiwLb8JzHMgI3db M+ZYih4s6Sva7LG5bLDLEFEQwRfgX7b3wTflb2pCeNuNgDZS3YOSUy9TM+NyrMMg FD9YFdP/va/jXDJekPeF6NAXErZqN6nqCXaQHsACtGwpd9G5KibachvUOp4LHeIr 8b2UvVngtv2EwmzJDOyKCPAuT0EceqbJjzjDwgcmpFTLRsEj9sra1iBTrEjj6uH7 hHZj2n8jv9U7Cyz8Lh39OL5PEHo46tkSoun0Vb/Xy3Sa0r6N1RQup05tS/0Lf7i6 MERHq61/u07SR1aid5J22QCmBGK6KgJjH2dWR5uU5ivfnOFkhMLSuqE/RIxt+eJt 242f2xfZ19KMQXKDjXQOUmHbGkjJEECocTGkImSRLxfEP1xhLoNV/vAN6lUcaCoJ 1+xOnCIxFOQXOKsWNbAnSNafRYTK4863xnnbjdlQYB8qV7TmVZTioxjKqUJB2TZc wK3lkz9SXRpjlGXD6RTzD15d3DTnDWkoqDBxL2RJIA0fX3gAda70u86cjPUExX33 VN5GNERaU9YwYqPwckJoer2NHFH60nr8oyftxQhQ9AKdW4IbZXrx+OWhcFUBV1H2 H7cAiu8eRILUSQ6YUEvJOi6PkhFxeUrXojlrLbwR3wl2f1RVb4u8ot7GsgQR2svn RHFwYBaUqxeWA4/dO4jr =OBXb -----END PGP SIGNATURE----- --IgjJ2PKSh+KhnqU7--