Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eUcj7-0000PV-Ai for pgsql-general@arkaria.postgresql.org; Thu, 28 Dec 2017 18:16:21 +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 1eUcj6-0005nY-Gq for pgsql-general@arkaria.postgresql.org; Thu, 28 Dec 2017 18:16:20 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eUcj6-0005nO-6P for pgsql-general@lists.postgresql.org; Thu, 28 Dec 2017 18:16:20 +0000 Received: from tamriel.snowman.net ([2001:470:e38f::11]) by makus.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1eUcj3-0004sK-5s for pgsql-general@lists.postgresql.org; Thu, 28 Dec 2017 18:16:18 +0000 Received: by tamriel.snowman.net (Postfix, from userid 1000) id 211DE5F795; Thu, 28 Dec 2017 13:16:16 -0500 (EST) Date: Thu, 28 Dec 2017 13:16:16 -0500 From: Stephen Frost To: Edson Carlos Ericksson Richter Cc: pgsql-general@lists.postgresql.org Subject: Re: Does PostgreSQL check database integrity at startup? Message-ID: <20171228181615.GF4628@tamriel.snowman.net> References: <20171227213314.GY4628@tamriel.snowman.net> <20171227215204.nucxo7b2ssmyznip@alvherre.pgsql> <20171228121651.GZ4628@tamriel.snowman.net> <42cda197-fead-a7e5-a7e2-750d98bc4eb2@simkorp.com.br> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="7HTELwohvzSXNJjc" Content-Disposition: inline In-Reply-To: <42cda197-fead-a7e5-a7e2-750d98bc4eb2@simkorp.com.br> User-Agent: Mutt/1.5.21 (2010-09-15) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --7HTELwohvzSXNJjc Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Greetings, * Edson Carlos Ericksson Richter (richter@simkorp.com.br) wrote: > Would be possible to include in future versions: > 1) After start standby, standby run all WAL files until it is > synchronized with master (current behavior) > 3) Before getting into "accept read only queries", check if all base > files have same size as master server (new behavior). In case > something is different, throw an error and stop database startup? > 4) Then start "accept read only queries" (current behavior) I'm afraid it wouldn't be nearly that simple with a running system. If you're that concerned about it, you could shut down the primary, verify that the replica has fully caught up to where the primary was, and then compare the file sizes on disk using a script yourself (excluding the temporary files and unlogged relations, etc, of course). I'm not completely sure that there isn't a valid reason for them to be different even with everything shut down and fully caught up, but that seems like the best chance way to match things up. On a running system where lots of processes are potentially writing to different files across the system, getting a point-in-time snapshot of the file sizes across the entire system as of a certain WAL point (so you could replay to there and then compare on the replica) seems unlikely to be possible, at least with just PG. Perhaps with help from the OS/filesystem, you might be able to get such a snapshot. Do you have some way of knowing that such a check would have actually caught this..? Isn't it possible that the file became zero'd out sometime after the replica started up and was running fine for a while? One of the questions I asked earlier drove at exactly this question- why weren't there any errors thrown during WAL replay on the replica, given that the relation clearly appeared to be modified after the replica was built? Another thing which could be done would be to look through the WAL for references to that file and see what the WAL included for it. Also, really, if this is happening then there's something pretty wrong with some part of the process and that simply needs to be fixed- just throwing an error saying the replica isn't valid isn't really good for anyone. Where the issue is, I don't think we have any idea, because there's a lot of details missing here, which is why I was asking questions about the other data and information since it might help us figure out what happened. Perhaps it's an issue in the OS or filesystem or another layer (though there should really be logs if that's the case) or maybe it really is a PG issue, but if so, we need a lot more info to debug and address it. Thanks! Stephen --7HTELwohvzSXNJjc Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBCgAGBQJaRTTvAAoJEO1sijiDR2RVVucP/i6hO9/vS37XAJiffORao8KD 6t0WVrsWp1OBXp9MIGZ61TiXXPJv2Q4dM3UMJ/WxoVu3vcYdj2tSYpTZi8hRgSyB y0WZFZEYFUFTHS2CsPmNqIuLXKi3+pDo6xYHVnk9sKz6RDfvmpJCvNUdt5SqKk2S 8dMSpWq6twvVSOFa0fGhWuwlUv6cjFLlx6AeUpnVrTQeAUga5WGsT+KjfAdkLbkP Rli44Iv82XULvYuxF0pvLnvM45FCE2BV9Gm5JU/3P13kReeTBvem1QQwIp3ZZnsr 810/MoCJFFMfVc3Z1AUjhXbgA3954Z+jLSgdlOmUKVbnuC85jwnPwS2feXjI9dIU ApyZV6Qfd5MxX5lOOcFmSn+G5m+EI985U67ucpKNiICbcftlCmz+8fvPoLRhyzIi Stm8rMsECMBOS8HcckBRkwGOzQdXykPDYcdkwsALi/qY1ZJ+4NjxUzeYNE+kaqJS Po2L4dWfxc1hk64MSqCE68XJr04iTazcelWB02D902mVkLl61EdYRKcGmk6fgjGu 2OjpuVh/2ajRgKZ56Kq578LW3+eRgjy6udESyxFrt5QYsA883+FQkdWFN6YEYVFX 0DPeMXUUeFemO1tskMyVQp1Qi/91DKWZWYyRnfnWd1Wk9OIgJIxmDPxVTxITtyiL HUtrhd4/C7Z4TTdqc3Mp =Ini+ -----END PGP SIGNATURE----- --7HTELwohvzSXNJjc--