Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eTrVS-0007Tv-8D for pgsql-general@arkaria.postgresql.org; Tue, 26 Dec 2017 15:51:06 +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 1eTrVR-0002ZA-Ah for pgsql-general@arkaria.postgresql.org; Tue, 26 Dec 2017 15:51:05 +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 1eTrVQ-0002Ym-W3 for pgsql-general@lists.postgresql.org; Tue, 26 Dec 2017 15:51:05 +0000 Received: from server5.simfrete.com ([177.52.183.19]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1eTrVO-0008SY-5t for pgsql-general@postgresql.org; Tue, 26 Dec 2017 15:51:03 +0000 Received: from [192.168.10.30] (unknown [177.52.183.17]) by server5.simfrete.com (Postfix) with ESMTPSA id C04A02447F0; Tue, 26 Dec 2017 13:54:07 -0200 (-02) Subject: Re: Does PostgreSQL check database integrity at startup? To: Pavel Stehule Cc: Martin Marques , "pgsql-general@postgresql.org" References: <1e5f1c84-7a65-331e-3d4b-fce95a5e8fc4@simkorp.com.br> <2736ceab-73ad-489d-d455-43d38b90cc60@2ndquadrant.com> <5fb54d4c-7f11-b4b2-b33f-1d87e8082524@simkorp.com.br> From: Edson Carlos Ericksson Richter Message-ID: <48b7e2bf-2c53-721d-5cee-b04b7a8c6c98@simkorp.com.br> Date: Tue, 26 Dec 2017 13:50:59 -0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.5.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B941C3767B7BB27D2F99B6CC" Content-Language: pt-BR List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------B941C3767B7BB27D2F99B6CC Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Em 26/12/2017 13:40, Pavel Stehule escreveu: > > > 2017-12-26 16:37 GMT+01:00 Edson Carlos Ericksson Richter > >: > > Em 26/12/2017 12:25, Pavel Stehule escreveu: >> >> >> 2017-12-26 14:44 GMT+01:00 Martin Marques >> > >: >> >> El 26/12/17 a las 09:52, Edson Carlos Ericksson Richter escribió: >> > Recently I had a problem with a base file with size 0 in a >> standby server. >> > >> > This raised one question: does PostgreSQL (9.6.6) check >> base integrity >> > at startup? >> > >> > At least if there are 0 byte size files in base dir? Or >> CRC? Something? >> >> Yes it has CRC check, but only if you initialize the cluster with >> --data-checksums, and there's a price to pay in performance. >> >> >> It has CRC check, but it is used in runtime - when data are >> necessary >> >> So Postgres usually check nothing on start - few system tables >> and indexes >> >> Regards >> >> Pavel >> >> >> -- >> Martín Marqués http://www.2ndQuadrant.com/ >> PostgreSQL Development, 24x7 Support, Training & Services >> >> > > Any tips to make database server don't start if corrupt? > If I can change the startup script to make some checks before > effectively starting the database, what would be the recommendations? > > One that seems obvious to me are empty data files (something like > "find -size 0 $PG_DATA/base")... > But I'm sure that more experienced PostgreSQL DBA would have more > tests to check before startup. > > > I don't think so anybody does it. Reading 1TB database needs more then > few hours. > > Regards > > > > Thanks, > > Edson > > I'm rebuilding the standby server for two days already, with 23% of completion status... If lost the database and backups because of that failure, it would be a giant disaster. Few hours checking integrity would be acceptable... Specially if I can run it on standby only. Regards, Edson --------------B941C3767B7BB27D2F99B6CC Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit Em 26/12/2017 13:40, Pavel Stehule escreveu:


2017-12-26 16:37 GMT+01:00 Edson Carlos Ericksson Richter <richter@simkorp.com.br>:
Em 26/12/2017 12:25, Pavel Stehule escreveu:


2017-12-26 14:44 GMT+01:00 Martin Marques <martin.marques@2ndquadrant.com>:
El 26/12/17 a las 09:52, Edson Carlos Ericksson Richter escribió:
> Recently I had a problem with a base file with size 0 in a standby server.
>
> This raised one question: does PostgreSQL (9.6.6) check base integrity
> at startup?
>
> At least if there are 0 byte size files in base dir? Or CRC? Something?

Yes it has CRC check, but only if you initialize the cluster with
--data-checksums, and there's a price to pay in performance.


It has CRC check, but it is used in runtime - when data are necessary

So Postgres usually check nothing on start - few system tables and indexes

Regards

Pavel

--
Martín Marqués                http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services



Any tips to make database server don't start if corrupt?
If I can change the startup script to make some checks before effectively starting the database, what would be the recommendations?

One that seems obvious to me are empty data files (something like "find -size 0 $PG_DATA/base")...
But I'm sure that more experienced PostgreSQL DBA would have more tests to check before startup.

I don't think so anybody does it. Reading 1TB database needs more then few hours.

Regards

 

Thanks,

Edson

I'm rebuilding the standby server for two days already, with 23% of completion status...
If lost the database and backups because of that failure, it would be a giant disaster.
Few hours checking integrity would be acceptable... Specially if I can run it on standby only.

Regards,

Edson
--------------B941C3767B7BB27D2F99B6CC--