Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4hpp-0004jF-CR for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 08:04:57 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h4hpo-0000wX-4C for pgsql-hackers@arkaria.postgresql.org; Fri, 15 Mar 2019 08:04:56 +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_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4hpn-0000pz-TL for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 08:04:55 +0000 Received: from gauss.credativ.com ([93.94.130.89]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h4hpk-0000rk-PA for pgsql-hackers@lists.postgresql.org; Fri, 15 Mar 2019 08:04:54 +0000 Received: from gauss.credativ.com (localhost [127.0.0.1]) by gauss.credativ.com (Postfix) with ESMTP id 5E6491E3E86; Fri, 15 Mar 2019 09:04:51 +0100 (CET) Received: from kohn.fritz.box (ppp-188-174-36-161.dynamic.mnet-online.de [188.174.36.161]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: mba@gauss.credativ.com) by gauss.credativ.com (Postfix) with ESMTPSA id 086E71E39F1; Fri, 15 Mar 2019 09:04:50 +0100 (CET) Message-ID: <1552637091.9697.18.camel@credativ.de> Subject: Re: Offline enabling/disabling of data checksums From: Michael Banck To: Michael Paquier Cc: Magnus Hagander , Fabien COELHO , Sergei Kornilov , PostgreSQL Developers Date: Fri, 15 Mar 2019 09:04:51 +0100 In-Reply-To: <20190315025027.GN3493@paquier.xyz> References: <20190313021621.GP13812@paquier.xyz> <20190313093150.GE2988@paquier.xyz> <1552473675.4947.62.camel@credativ.de> <1552475364.4947.64.camel@credativ.de> <20190313115633.GA1878@paquier.xyz> <20190314043936.GH3493@paquier.xyz> <1552577180.9697.4.camel@credativ.de> <20190315025027.GN3493@paquier.xyz> Organization: credativ GmbH Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.22.6-1+deb9u1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Hi, Am Freitag, den 15.03.2019, 11:50 +0900 schrieb Michael Paquier: > On Thu, Mar 14, 2019 at 04:26:20PM +0100, Michael Banck wrote: > > Am Donnerstag, den 14.03.2019, 15:26 +0100 schrieb Magnus Hagander: > > > One big-hammer method could be similar to what pg_upgrade does -- > > > temporarily rename away the controlfile so postgresql can't start, and > > > when done, put it back. > > > > That sounds like a good solution to me. I've made PoC patch for that, > > see attached. > > Indeed. I did not know this trick from pg_upgrade. We could just use > the same. > > > The only question is whether pg_checksums should try to move pg_control > > back (i) on failure (ii) when interrupted? > > Yes, we should have a callback on SIGINT and SIGTERM here which just > moves back in place the control file if the temporary one exists. I > have been able to grab some time to incorporate the feedback gathered > on this thread, and please find attached a new version of the patch to > add --enable/--disable. Thanks! One thing stood out to me while quickly looking over it: + /* +  * Flush the control file and its parent path to make the change +  * durable. +  */ + if (fsync_fname(controlfile_path, false, progname) != 0 || + fsync_parent_path(controlfile_path, progname) != 0) + { + /* errors are already logged on failure */ + exit(1); + } ISTM this would not run fsync_parent_path() unless the first fsync fails which is not the intended use. I guess we need two ifs here? Michael -- Michael Banck Projektleiter / Senior Berater Tel.: +49 2166 9901-171 Fax: +49 2166 9901-100 Email: michael.banck@credativ.de credativ GmbH, HRB Mönchengladbach 12080 USt-ID-Nummer: DE204566209 Trompeterallee 108, 41189 Mönchengladbach Geschäftsführung: Dr. Michael Meskes, Jörg Folz, Sascha Heuer Unser Umgang mit personenbezogenen Daten unterliegt folgenden Bestimmungen: https://www.credativ.de/datenschutz