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 1h3dcz-0006f4-QS for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Mar 2019 09:23:19 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1h3dcw-0000Ct-Lt for pgsql-bugs@arkaria.postgresql.org; Tue, 12 Mar 2019 09:23:14 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h3dcu-0000Ci-UW; Tue, 12 Mar 2019 09:23:14 +0000 Received: from out2-smtp.messagingengine.com ([66.111.4.26]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1h3dcr-0004St-7u; Tue, 12 Mar 2019 09:23:11 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id EBCF8221C9; Tue, 12 Mar 2019 05:23:07 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Tue, 12 Mar 2019 05:23:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= date:from:to:cc:subject:message-id:references:mime-version :content-type:in-reply-to; s=fm1; bh=ZafadPOXrjWCRBx4Q1RGgIF556s Sb1RjaR+Eh4kH+ac=; b=K8ZJC2EucBoDrtGcl/ejztKOe4j6s2jMhwtpGKchDJe 7Z+DPIj81mt8huhBb4+9Xm5T4g9y/FVArduphNpPyHQen6QKwt2alIWiok56CePF 0r1yjTFfT4cM68sAV/8rk3ccH+yW+Le+AzGQ8ReahnpHOBnQGkzwR4sP12CJb918 fcgANcT/X7dye3M3JIGEZQ8IfVCEj+YHrF/nQqxR0RkatPtZoz42r8RNZdbfXpO6 Thqb84GDl1gSMUrUhqcN5PNBXJfGQ3VLcBu6QqpX/YlPuxAyDfGa5+hFVtNAKvwC wq3t21le3B0kxyDu3PyciU4sfqOMVk00zA3wSlQw0AA== 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-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=ZafadP OXrjWCRBx4Q1RGgIF556sSb1RjaR+Eh4kH+ac=; b=6+rniRSgOms5PrqS2oA1ui +JgoznMpobTK1Sk2myjBTiOGOukpv//Ye/pXMvZG2ubtMJgTpJdFD+VYJ+UP7paZ jVfiiLEgZd0Zbtp/KJZco4iqFT3468LELmH2jBrWUVUFNM0MP3x7+CiT1mytXwz/ w8cn531y0loBPjwv4ugFMeFOTinuuFu18Y2Cca/cFFgHS2aq2Tvs3qeSKyaL4xfU mRMFbxOvtZWEifzFq+Hl+2wWiRDl6qo6/ta5Z6pfeqT0Y3vQeR+NgucvV3JtO3Pu sa4gPa+IWwVWSfpG5UbmpEBaf1jcYRbKjGV32k5uojhcAPTaecqidFX/yX2Xbk3w == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedutddrgeekgddtfecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenfg hrlhcuvffnffculdefhedmnecujfgurhepfffhvffukfhfgggtuggjsehgtderredttddv necuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesphgrqh huihgvrhdrgiihiieqnecukfhppeeiuddrvdduhedrudefjedrudeivdenucfrrghrrghm pehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiihiienucevlhhush htvghrufhiiigvpedt X-ME-Proxy: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 6E368E4481; Tue, 12 Mar 2019 05:23:04 -0400 (EDT) Date: Tue, 12 Mar 2019 18:23:01 +0900 From: Michael Paquier To: Mithun Cy Cc: pgsql-bugs@lists.postgresql.org, pgsql-hackers@lists.postgresql.org, michael.paquier@gmail.com, fujii@postgresql.org, kuntalghosh.2007@gmail.com, Robert Haas Subject: Re: pg_rewind : feature to rewind promoted standby is broken! Message-ID: <20190312092301.GL13812@paquier.xyz> References: MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="z3ovhOgMYmj8MRdq" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --z3ovhOgMYmj8MRdq Content-Type: multipart/mixed; boundary="75WsOQSofUOhcSOp" Content-Disposition: inline --75WsOQSofUOhcSOp Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Mar 12, 2019 at 01:23:51PM +0530, Mithun Cy wrote: > I think pg_rewind's feature to rewind the promoted standby as a new > standby is broken in 11 Confirmed, it is. > Also I have tested same in version 10 it works fine there. >=20 > Did below commit has broken this feature? (Thanks to kuntal for > identifying same) > commit 266b6acb312fc440c1c1a2036aa9da94916beac6 > Author: Fujii Masao > Date: Thu Mar 29 04:56:52 2018 +0900 > Make pg_rewind skip files and directories that are removed during server = start. And you are pointing out to the correct commit. The issue is that process_target_file() has added a call to check_file_excluded(), and this skips all the folders which it thinks can be skipped. One problem though is that we also filter out pg_internal.init, which is present in each database folder, and remains in the target directory marked for deletion. Then, when the deletion happens, the failure happens as the directory is not fully empty. We could consider using rmtree() instead, but it is a nice sanity check to make sure that all the entries in a path have been marked for deletion. Just removing the filter check on the target is fine I think, as we only should have the filters anyway to avoid copying unnecessary files from the source. Attached is a patch. What do you think? (check_file_excluded() could be simplified further but it's also nice to keep some mirroring in this API if we finish by using it for target files at some point.) -- Michael --75WsOQSofUOhcSOp Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="rewind-filter-fix.patch" Content-Transfer-Encoding: quoted-printable diff --git a/src/bin/pg_rewind/filemap.c b/src/bin/pg_rewind/filemap.c index bb4ffd0e38..a2cd317c72 100644 --- a/src/bin/pg_rewind/filemap.c +++ b/src/bin/pg_rewind/filemap.c @@ -334,12 +334,11 @@ process_target_file(const char *path, file_type_t typ= e, size_t oldsize, file_entry_t *entry; =20 /* - * Ignore any path matching the exclusion filters. This is not actually - * mandatory for target files, but this does not hurt and let's be - * consistent with the source processing. + * Do not apply any exclusion filters here, the folders marked for + * deletion on the target should be entirely empty, and we also + * check after pg_internal.init which is present in each database + * folder. */ - if (check_file_excluded(path, false)) - return; =20 snprintf(localpath, sizeof(localpath), "%s/%s", datadir_target, path); if (lstat(localpath, &statbuf) < 0) --75WsOQSofUOhcSOp-- --z3ovhOgMYmj8MRdq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlyHenUACgkQnvQgOdby QH0cuQ/+L7RdWjNPU9anV9w3kSBTHJdGpvPfNQkBVS43/3k3BMJG71DJzynSZt6u OYGrZ3hwrKfdWMTjxUS8g7doL9Ip5Aa+qfVuWAi5xnhcboZdRynszo0kcZMRzHay djanTb/xPDR0hOB5dH0lA8WZtoEYXNytomKSClXxktg2K1y/VkqKZ6WFn4RbfJwg OiJdFZJ+zBBLa7b8SDEWCoS/h2XN47U5rfUnt5HsTMkaCwpErevh4NIA+afWG8qs /0en4N3/oAX0080kyfbf5w5BAZXmiaS7CbgB8rvlpHVsiQJkh4jz3p9K094jYPUp TGXD2sfYIQO76zFliA6MwHY5ijOuK5HDds3GMppC4BnmSDLOCXh6wmRW+h2MovL9 tcOv1hrRf4rPPKt/QRjgaANpMh4kxyMh6CvnkP0Q4PT5dtQ4zQU09Lkg2WQ6rcKJ rwPVgvLa8+FjWFu7DDWETju3kBBMtRRPr6OWz233uX3FHhUy5CMjIvpJ+NGPQ6li 8ISNLZDF038JxR/M340SF3wc8lk7/AAZjUvoRJyi0MdBypCiG/i/c89pJu9mTi+w e09Fvw44cUXHqx0c+Iqu/G+oTW23Q6OQR5sBThkHJ3SMunCbtyIa+Yv0DAGXzV/r XEeyM1JPPdEh7nHIhWZ9E3/Oe3BPgsGfWCEmoBkpprpBt0yNLrM= =ArfI -----END PGP SIGNATURE----- --z3ovhOgMYmj8MRdq--