Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4wFM-0006Lp-3Y for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Apr 2018 22:23:44 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1f4wFI-0003OW-Vz for pgsql-bugs@arkaria.postgresql.org; Sat, 07 Apr 2018 22:23:40 +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.89) (envelope-from ) id 1f4wFH-0003OL-6v for pgsql-bugs@lists.postgresql.org; Sat, 07 Apr 2018 22:23:40 +0000 Received: from [66.111.4.29] (helo=out5-smtp.messagingengine.com) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1f4wF9-0007hN-HE for pgsql-bugs@postgresql.org; Sat, 07 Apr 2018 22:23:38 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 6CDE92076C; Sat, 7 Apr 2018 18:23:09 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 07 Apr 2018 18:23:09 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:content-type:date:from:in-reply-to:message-id:mime-version :references:subject:to:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=U0xKvUAa6JLSv8kBwWQ7eMHeLte5jSBjmEup2ECRb2k=; b=M2mWEz0x zqjbW4ZP4LWzicGXxQpJ8fbL2+tN1Hg4aFAhWhXiJ3UaQyi274ti1D0u2u0xP+ik MHU1/tr1dYTMBGTUJA3MujuSKsAoUJk/LEgFgbSoDAjQtJBwow9jAnC/bve/NaMh V1UxWwID/nXL3wOgBhownbn9q9gTHjBaqcrwJrfUXCGOWIgetHL2Y74u2kvYByPk c24xQcgsPZZoun1RXQOkWoda+QDtw6yDeqc/UOj371qMRxZaUBWYa/ClLp2FjuaO QZPpq31/pBZYH899P/x59D4jZ7ZjulS9NB3eHdWtrxANfik1vs0pykLCUtWCWZL8 3ZT6zsG8UFGRkg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm2; bh=U0xKvUAa6JLSv8kBwWQ7eMHeLte5j SBjmEup2ECRb2k=; b=F4TomWSKbpTDvv2KSdq1kQLYA9FJOz1wJikKLM7+IYpGR BcmCS29dG10UmyPQSZYMVKLJgt7IzriCFBqKuLYdBrf6YRXlifExH4xRPBU5wF5/ U8PjfPPto+apuiHNvb99cWYEkKTw4s6khwHLaYRRNmqbx0uNnmpnBsBqNh2k0U5D UlMbMHucUf9wy3js8dNy1xIVFqYwtg0oTBsU+2U2QbNaK2LoCrFJJSYgVjrktp2U ld0wS8hukJ9dzfI7c3gytqiFmqWmAvbBrYBNSJ0H6Vu/4jIi8NmcrTgVQM4dixjh Tx/XBmvNpRsBAqasJaDJesNWXd5Ca6yUa7Z9cGfvQ== X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 2E3FEE4924; Sat, 7 Apr 2018 18:23:06 -0400 (EDT) Date: Sun, 8 Apr 2018 07:22:58 +0900 From: Michael Paquier To: Tom Lane Cc: TipTop Labs , Dmitry Dolgov <9erthalion6@gmail.com>, Masahiko Sawada , PostgreSQL mailing lists Subject: Re: BUG #14999: pg_rewind corrupts control file global/pg_control Message-ID: <20180407222258.GA3345@paquier.xyz> References: <30255.1522711675@sss.pgh.pa.us> <20180403024110.GB1621@paquier.xyz> <20180404072625.GB2208@paquier.xyz> <22961.1522867812@sss.pgh.pa.us> <20180405013818.GC1732@paquier.xyz> <20180405065840.GH1732@paquier.xyz> <15971.1523116292@sss.pgh.pa.us> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="8t9RHnE3ZwKMSgU+" Content-Disposition: inline In-Reply-To: <15971.1523116292@sss.pgh.pa.us> X-Host-Lookup-Failed: Reverse DNS lookup failed for 66.111.4.29 (deferred) List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --8t9RHnE3ZwKMSgU+ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Sat, Apr 07, 2018 at 11:51:32AM -0400, Tom Lane wrote: > In any case, after another look at the code, it seems to me that it'd be > pretty easy to get pg_rewind to notice at the start whether a target file > it plans to overwrite is read-only: process_source_file is already doing > an lstat per file, so I think a permissions check there wouldn't add much > overhead. So at that point we could either bail out without damage, or > decide to skip the file. Yes, that's one of the methods I mentioned in my previous email. Now, do we want to fail the run immediately if such a file is found? Or do we want to report at once all such files so as the user does not need to run multiple times pg_rewind. The latter would be much more useful. A downside here is that the file from the source would still be fetched and copied on the target. So a file which was in read-only would become basically writable. Don't think that it is a big deal as the has superuser rights at this point, but that's worth mentioning. > We could still lose if permissions change midway > through the run, but that's the sort of situation I think is OK to fail > in. If the file system switches to read-only in the middle of the run, I see no way to recover from that. That would be bad luck, but it is way better to fail hard and let the user that something has gone wrong. I still think that we want to document that if pg_rewind fails hard midflight, then the only thing safe enough moving forward is to use a new base backup. -- Michael --8t9RHnE3ZwKMSgU+ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlrJRMIACgkQnvQgOdby QH25vxAApmPVJFyV96vA15HO44zMZWb7QoF+vN0fHmm5rg261l7iQ1/axj3fAE45 XuzmrN4106V3HMMAKOFwotwV7lrnIie5oMpHgzGJye2YWXtU8yoqCRzJcyqFV2rJ 1Ndf/RQWaAeKNimLWrvYKvHDM0nWFeDJIrSEZI8mLNa++eMnE5h1sLdEej1VcD9B henOqN9LyHmN9FuiM1/1tinWwCqtj/h1BrcsZjgevx2plEk5DdBBW8VyhC7tCw1z S6K0QCBTB9AaY5+dH+It0ggAzb6hqEWNam54/Go6fD9TwMSKRk5PmLM/NdZuDQJU Q227tC6PXmaOgzv2JstotdJ8vcJWNVaxdg+EKVyy3JJZDXbK9dF0YIPwzs/gggdj 2O/IDXza+3m9zQnc4AyjcJVibJfwX7gLKhFLQbOE+b+udrcmvawABqI7EbSvEglU dEkdybWH+1NgrqkKHzYDJhde9nkSKSoLVAsfz0XetpyPL9KXgYznXOQJAlanih8M DI6MYDhYx3nbRQ+rXOKZE+3/h8j0DkJLv1O3yQYL4aGcGK47nrt0hmox6+DKa4WT a7Md96SZOrP3F8t2Cso5Aflid18t5Ot2PifsbaHEMaNN7man2IgxyQsJ84Aydge4 G80yOfR5xBzt64mT0fSvvLEufttQRlWM1l/MEO8wZJdblG9A7o8= =U67K -----END PGP SIGNATURE----- --8t9RHnE3ZwKMSgU+--