Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g3Cg5-0000Bv-HI for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Sep 2018 04:04:26 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g3Cg3-0002lE-Nd for pgsql-hackers@arkaria.postgresql.org; Fri, 21 Sep 2018 04:04:23 +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 1g3Cg0-0002Lz-HW for pgsql-hackers@lists.postgresql.org; Fri, 21 Sep 2018 04:04:22 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1g3Cfu-0003kq-Ju for pgsql-hackers@postgresql.org; Fri, 21 Sep 2018 04:04:17 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 5BBF92204F; Fri, 21 Sep 2018 00:04:13 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Fri, 21 Sep 2018 00:04:13 -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= fm2; bh=1NdAqxY29/lTKmUWfPQqvGTfpvs064V05S2eqzix3xg=; b=DOR0+Zzk 7+PQts00+XzIvILr/x9Pwjic+Bz+wOwqo2nipMN1cJGAh1pNgO9Gw29KoTOAAYL5 4xPE5m/g6ILY1bzKBqANy18uQ3mHhGhVpS9DT6GrkWdInQ5/QH2KmCmuDWfnq5Zz WMDEbsnz/Q0lPWn4cM+aLjkAJ8/s5c8SQDch3LDZUN/iV7aCssSOtQkENxpCGLQa cU4fL3E1iZTHcT8aue8OTzoDlBZwwUFhm+LzNgFDaE7WPhhT52gYeHJgd7EtwUfk oGD8lCjsmYNpI9zoB4fWq9g+v+Nh8tcFD5sdDSwD2DQM5/MyKn08u2aVRpHPwzxV o8Zt4IRNnyKxIg== 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=fm3; bh=1NdAqxY29/lTKmUWfPQqvGTfpvs06 4V05S2eqzix3xg=; b=kQQt3WJMiaYqZtwPCptYyPqlqhBoz+413IYp7zrQZFyhj RK8k6Kn9Jq0q9ysW8kKimpz/u593rkoQ2CmmPjt+T8WaAz3LXg9u755z9gvsajQr 4wrhbebMbMtUjAofoQpJKeVokoAI1X4rR3RXrmxtHh6dD+dczJm4Jcghkdzzsl3r Wkt95iMksbXEtClKQ2vxCnlzcpTH8FtOVojp5tV19n0f57CsFfn9jrpY2L6ssNDO Mlkec3nJ8o2wYPt6URz29W6TegH4UzChxGBMDclTGgbdUeTPfJoPTeerHPqo++a4 Z2xhbReOOoQtnlG6vZoUbnDpPMsCbnP8ftlMWNx/Q== X-ME-Proxy: X-ME-Sender: Received: from paquier.xyz (mp76f1f9fd.ap.nuro.jp [118.241.249.253]) by mail.messagingengine.com (Postfix) with ESMTPA id E5EFBE4121; Fri, 21 Sep 2018 00:04:09 -0400 (EDT) Date: Fri, 21 Sep 2018 13:04:07 +0900 From: Michael Paquier To: Kyotaro HORIGUCHI Cc: amit.kapila16@gmail.com, robertmhaas@gmail.com, hlinnaka@iki.fi, dilipbalaut@gmail.com, pgsql-hackers@postgresql.org Subject: Re: Problem while setting the fpw with SIGHUP Message-ID: <20180921040407.GF1338@paquier.xyz> References: <20180906233728.GR2726@paquier.xyz> <20180914072655.GI29332@paquier.xyz> <20180918.161542.79085818.horiguchi.kyotaro@lab.ntt.co.jp> <20180919052034.GI1650@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="oOB74oR0WcNeq9Zb" Content-Disposition: inline In-Reply-To: <20180919052034.GI1650@paquier.xyz> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --oOB74oR0WcNeq9Zb Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Wed, Sep 19, 2018 at 02:20:34PM +0900, Michael Paquier wrote: > On Tue, Sep 18, 2018 at 04:15:42PM +0900, Kyotaro HORIGUCHI wrote: >> My latest patch tries to remove the window by imposing all >> responsibility to apply config file changes to the shared FPW >> flag on the checkpointer. RecoveryInProgress() is changed to be >> called prior to UpdateFullPageWrites on the way doing that. >=20 > I still need to look at that in details. That may be better than what I > am proposing. At quick glance what I propose is more simple, and does > not need enforcing a checkpoint using SIGINT. I have finally looked at the patch set from Horiguchi-san here: https://www.postgresql.org/message-id/20180828.193436.253621888.horiguchi.k= yotaro@lab.ntt.co.jp And actually this is very close to what my proposal does, except for a couple of caveats. Here are my notes: 1) The issue with palloc() happening in critical sections is able to go away, by making the logic behind UpdateFullPageWrites() more complicated than necessary. With the proposed patch, UpdateFullPageWrites() never gets called by the checkpointer until the startup process has done its business. I would have believed that keeping the check to RecoveryInProgress() directly in UpdateFullPageWrites() makes the logic more simple. That's actually what my proposal does. With your patch, it would be even possible to add an assertion so as this never gets called while in recovery. 2) At the end of recovery, if there is a crash before the checkpointer is able to update the shared parameters it needs to work on away, then no XLOG_CHANGE_PARAMETER record is generated. This is not a problem for normal cases, but there is one scenario where this is a problem: at the end of recovery if the bgwriter is not started, then the startup process creates a checkpoint by itself, and it would miss the record generation. 3) SIGINT is abused of, in such a way that the checkpointer may generate two checkpoints where only one is needed post-recovery. 4) SyncRepUpdateSyncStandbysDefined() would get called even without SIGHUP being reached. This feels also like a future trap waiting to bite as well. When I see your patch, I actually see the same kind of logic as what I propose which is summarized in two points, and that's a good thing: a) Avoid the allocation in the critical section. b) Avoid two processes to call UpdateFullPageWrites at the same time. Now the points mentioned above make what you are proposing weaker in my opinion, and 2) is an actual bug, side effect of the proposed patch. -- Michael --oOB74oR0WcNeq9Zb Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlukbbcACgkQnvQgOdby QH2HlQ/+OuGTZ/9E0Hmiwei5mhjAe8EpQhTYHAwy6pNMSH3AV1SNMrkWIvV60402 f10EHXeJc+5SHDfgPgssgnzm8Y2goDRBoWcJ4FC8AwboNX8K7zlFm7ZMx2y58Rbc /bnrbMcfU8DTolKyEIip2ikc23RxNMrC9qnM5Do5Yal4/baPjj5Ji1qawAsKn6cX ++pxOWtChczzKGGiGPVGJMX/3P6MQaQBCr1O/B2ihCiOfFBZvquoemmdWdAtITOk O102HDfgWya6ldGjmKxcV+oxT5fZEpn9BhIhBnqFhjGHS5CBHtmBsTO2xmN5MEW4 9lFVYRSq1AxfJEfTCWnprbpWcVAlJdSakgtF1q1YcihSDn4cFx3PdvbwS3Da2FAE nUgqxXQYZWPhCHBMwpEvDSof9OCGgDyUffZQ08st3Rb/I6KNV7IG0GBMvXSU5q1Z UNO/HaA+VJ3wu2U2U/JxMU9wDvy2AzmXHla5nGbtoAQw9VfBWyRsSKmF4vO+mPhJ hMxCOVoh2tiWVci8rux2dp2uQy2BwOQ9SP3nG7Fu+8ODyGQtNPDDFZPqipXQ7nos SLxywlOzhH+XRRp0JT2Ix1EbO4JBgz1TfTauoc6IckfnlahF4oDzVF0e8aZkIA66 D8LqEtone8+Xsv9QU2kvHYL3t5pJkfaHdpof2bWsooIPSBUzHBc= =chey -----END PGP SIGNATURE----- --oOB74oR0WcNeq9Zb--