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 1g29bO-0005XS-9c for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Sep 2018 06:35:14 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1g29bM-0007XU-9X for pgsql-hackers@arkaria.postgresql.org; Tue, 18 Sep 2018 06:35:12 +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 1g29bL-0007XH-VH for pgsql-hackers@lists.postgresql.org; Tue, 18 Sep 2018 06:35:12 +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 1g29bE-0001KW-L6 for pgsql-hackers@postgresql.org; Tue, 18 Sep 2018 06:35:10 +0000 Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id A0CD820931; Tue, 18 Sep 2018 02:35:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Tue, 18 Sep 2018 02:35:03 -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=7Svd0CAllM52MCjfWwY41B36jfjtwG/5mwJn4NR/Fpc=; b=V9zRqxDM nQvbTpm9p5ue3jQzKUYzweO85mNRPSBxmXJD0Pqc0vuBqeBkO5yLp1OSyHOlI3ov d4ximmmqdCKIf1z2pv/aEfRZByad2jUscN9+rpq9Tz+PXvoTc8WSF9/0IwvZ4iul 1x3VcEjDONDbpBng1ezsEwRBFU3JZIA060DyKTkNwM2eg70PQGqg2cFiqYfirrZS IwECnXfqMRkQF5ZH23qgbQq7MxFALUvcodWHKNGe/7d59xu+f44FuO7w1wo4XBwb UjVShZfTZpuGZ7rXd401Kk/tx0rEeWtKdx2t65KgpM9EqCSP25KcNFdHfvT0i7G9 GZOwTcBvuAKi8Q== 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=7Svd0CAllM52MCjfWwY41B36jfjtw G/5mwJn4NR/Fpc=; b=tWqRT9j+sMISp4FPpmQMi8YUv77VGpPorIZo1ejPg/rKZ 5PueYwfoOoVDLp8I8GpQzPYPAfTi5PO4FbpMKUe9X9VgAlByFKW2C8pNCtFIqBg7 6z7OsrbLfL4XVmjyDqPe6dCfPUipWgvUr63HGzTSb4i2U002ijiCiWRH6zooOkrK 6FpzGmHnyCbq6C9pOnygVvHkkImvdyYKHg8kb9dRbGlZl5qDfQ33RlcGL3lEtNFu MOeOhC/KkFIonHHTdGCB5iJVYR9ZpW4uiQHdwloZHajvq2ZuuTapa1GV6u99q7+F LdF751pLWyeT4yn/d5+baMKUVl60FuqQK4gQkcmIg== X-ME-Proxy: X-ME-Sender: Received: from paquier.xyz (c137162.net61215.cablenet.ne.jp [61.215.137.162]) by mail.messagingengine.com (Postfix) with ESMTPA id 688CD102D4; Tue, 18 Sep 2018 02:35:00 -0400 (EDT) Date: Tue, 18 Sep 2018 15:34:57 +0900 From: Michael Paquier To: Amit Kapila Cc: Kyotaro HORIGUCHI , Robert Haas , hlinnaka , Dilip Kumar , pgsql-hackers Subject: Re: Problem while setting the fpw with SIGHUP Message-ID: <20180918063457.GL31460@paquier.xyz> References: <20180728231911.GB1471@paquier.xyz> <20180801.162545.234930371.horiguchi.kyotaro@lab.ntt.co.jp> <20180828.193436.253621888.horiguchi.kyotaro@lab.ntt.co.jp> <20180906233728.GR2726@paquier.xyz> <20180914072655.GI29332@paquier.xyz> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="HxQt9wRz9wbL5Edg" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk --HxQt9wRz9wbL5Edg Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, Sep 14, 2018 at 04:30:37PM +0530, Amit Kapila wrote: > On Fri, Sep 14, 2018 at 12:57 PM Michael Paquier wr= ote: >> So, I have been working on this problem again and I have reviewed the >> thread, and there have been many things discussed in the last couple of >> months: >> 1) We do not want to initialize XLogInsert stuff unconditionally for all >> processes at the moment recovery begins, but we just want to initialize >> it once WAL write is open for business. >> 2) Both the checkpointer and the startup process can call >> UpdateFullPageWrites() which can cause Insert->fullPageWrites to get >> incorrect values. >=20 > Can you share the steps to reproduce this problem? This refers to the first problem reported on this thread: https://www.postgresql.org/message-id/CAFiTN-u4BA8KXcQUWDPNgaKAjDXC%3DC2whn= zBM8TAcv%3DstckYUw%40mail.gmail.com In order to reproduce the problem, you can for example stop the server in immediate mode. Then attach a debugger to it and add a breakpoint to UpdateFullPageWrites. You can check that XLOG insert has not been initialized yet by looking at xloginsert_cxt ot ThisTimeLineID. On a second session, switch full_page_writes to on or off, reload the parameters and then trigger a checkpoint. The important point is to trigger an inconsistency between XLogCtl->Insert->fullPageWrites and the value of fullPageWrites within the checkpointer context. With the checkpoint triggered, the debugger will stop at UpdateFullPageWrites immediately. At this point, you can simply check if fullPageWrites Insert->fullPageWrites have the same value or a different one. If the values match, simply switch full_page_writes and reload again, with the checkpointer still waiting at the beginning of UpdateFullPageWrites. SIGHUP will make the checkpointer process hang a bit, and then it will move on. At this point you will be able to see the failure: TRAP: FailedAssertion("!(CritSectionCount =3D=3D 0)", File: "mcxt.c", Line:= 731) 2018-09-18 15:06:39 JST [7396]: [11-1] db=3D,user=3D,app=3D,client=3D LOG: checkpointer process (PID 7399) was terminated by signal 6: Aborted > On a regular startup when there is no recovery, it won't allow us to > log the WAL record (XLOG_FPW_CHANGE) which can happen without above > change. You can check that by setting full_page_writes=3Doff and start > the system. Oh, good point, InRecovery is set to false in this case so that would be skipped. We can simply fix that by adding a flag, say "force" to UpdateFullPageWrites to allow a process to enforce the update of FPW even if RecoveryInProgress returns true, which would be the case for the startup process. -- Michael --HxQt9wRz9wbL5Edg Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAlugnJEACgkQnvQgOdby QH3mYQ/9HKz/Yn1fL8HaNhBZkUud6HzcwYprvE3BV8OhlTaobffAbz6ENl3qaWBq PQI34cJiFxDX27Zjhq8WyUp6Jn4Ah+yAIbNNb4KNJ7K94rzUL354ygNCMdn66Wd4 aW/Fasn3gYom+rfW5Rrn/LvAytX3GZEW7QsIzOIpV6vhvw6aGldZYRzA2G0TCOqJ EsvP//r8kcpQZjlhdd5nvJ1FTsndgRbIxJTeqknlDfqKxG0QKWh0my8JqwjR/5/2 DQGfseRMKuBZH4HBo744dKU0qMVV0mULy1eOy2YClc3pBAK1d103phdgqB+m7dao bgsKG9bDzKS/JXfS0ripbGgW3Cyjyu0wJGEbYSE/d4QP6xIikP4gP1XaVJjXFZQ6 dz8w/tGzAJV1jkrEuhkr90RIgZPoWpFQOXnkClIEQybK+p3tki5yFC8EJlX2xJMs rhO0XuUO/e35+IOe2nSTDfn9x6jDUmOqVULnwZQ7oan1+YyYCCEaAsjDd/ThBuVT PgVuTfv5j3U71KsP46GDmMQkExErvipeiL4x8N18Vhu3XaugqoJFavSR4cjd8/4Z lezR4FPRlPinA02uNyeCWE5igSrLMlLJPUeYwMYbh/fskI5sE3Uslz7VhM9w4wNQ u3xljFG0c+vEiYVv49BRhUXO/rPRR8ZGB9oisQ8/p1o21LjmqsU= =sTcv -----END PGP SIGNATURE----- --HxQt9wRz9wbL5Edg--