Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qd0fm-001t76-Oa for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Sep 2023 03:54:47 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1qd0fl-0085aZ-95 for pgsql-bugs@arkaria.postgresql.org; Mon, 04 Sep 2023 03:54:45 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qd0fj-0085a4-Je for pgsql-bugs@lists.postgresql.org; Mon, 04 Sep 2023 03:54:44 +0000 Received: from out4-smtp.messagingengine.com ([66.111.4.28]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1qd0fe-002scE-FX for pgsql-bugs@lists.postgresql.org; Mon, 04 Sep 2023 03:54:42 +0000 Received: from compute3.internal (compute3.nyi.internal [10.202.2.43]) by mailout.nyi.internal (Postfix) with ESMTP id 9A4BE5C00AC; Sun, 3 Sep 2023 23:54:35 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute3.internal (MEProxy); Sun, 03 Sep 2023 23:54:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paquier.xyz; h= cc:cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1693799675; x=1693886075; bh=8M AcSnFAO1aIt0T3qV5pLkv2AtVy8glgCCNqCWVb5RQ=; b=IG8ag+y6om2Idg5Z4J gfZ4Jx5E5hfMGxfCLMWjiO60H6h2TaM/ncx2FxnevBxMUy4TaZoxTrAaRqMoPIci F44uG7phg4edkit9BcMZExaNs/r+kpyUbTE01mX/1RUu7Mqx6mXuUYzfdrwxAN9s Riz6RAHr1Ey24dQKUYTfirOpJ7evhJxgO2G3MWiYP1PgTS7PkwAJenWaZuyLwbpG fWtIy4X0PTNSxJOKC86n7s6/QcR8HBdb+aNalR/6kVdPO8yIXSw/wnbTiiJ5lmlH io5QYfUciHrl6EKJjOIoutAPcW3YjssyOxwANOZHHj3tR4T6R8LNgPVuS9EB27rP L8uQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm1; t=1693799675; x=1693886075; bh=8MAcSnFAO1aIt 0T3qV5pLkv2AtVy8glgCCNqCWVb5RQ=; b=PktNJsrFAuBpk9V/6i51AWhVBPpaO sEJH3/+0Pe9t2BuGzDI89MK/dvqHEejfuQLAvoo8kdU77ejDEZYWx3aiIyyPiPgZ WkSWVu82bSjvcFCiK5GZ2qoFpt3ZftOcsoVKP9Q5xwaMBuu6VMQ/N84VulY/xtgn 3w9WN98qOzp+tEpcDBySeDafy1Kkmp+umNBf7LhJfhyRfay5YNR1nDrZL+qLBxBn Hb1xnalRJqOE4Z1Oa0T4TpuGCTLUXq5keAYbbjfR/v9/wCsPEzULQHhOkmCTn0yI yGIMO7mPNhPom399Cc3HyPJQem9X2fRsape83WSGH8a4Lh4YXYn5OzVLA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedviedrudegjedgjeekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne gfrhhlucfvnfffucdljedtmdenucfjughrpeffhffvvefukfhfgggtuggjsehgtderredt tddvnecuhfhrohhmpefoihgthhgrvghlucfrrghquhhivghruceomhhitghhrggvlhesph grqhhuihgvrhdrgiihiieqnecuggftrfgrthhtvghrnhepteelieefudffhffhtdetleeg geegfffhkeeuveetiefgudduvedutefggeeivdejnecuvehluhhsthgvrhfuihiivgeptd enucfrrghrrghmpehmrghilhhfrhhomhepmhhitghhrggvlhesphgrqhhuihgvrhdrgiih ii X-ME-Proxy: Feedback-ID: i0fe9450f:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sun, 3 Sep 2023 23:54:33 -0400 (EDT) Date: Mon, 4 Sep 2023 12:54:28 +0900 From: Michael Paquier To: Thomas Munro Cc: Sergei Kornilov , Noah Misch , Tom Lane , Kyotaro Horiguchi , exclusion@gmail.com, pgsql-bugs@lists.postgresql.org Subject: Re: BUG #17928: Standby fails to decode WAL on termination of primary Message-ID: References: <1641161693655508@ske52ucy55r5y36k.iva.yp-c.yandex.net> <222191693740067@6mha55xjikky5vne.iva.yp-c.yandex.net> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OLV1rviX9OPloDkZ" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --OLV1rviX9OPloDkZ Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Mon, Sep 04, 2023 at 03:20:31PM +1200, Thomas Munro wrote: > 1. In the place where we fail to allocate memory for an oversized > record, I copied the comment about treating that as a "bogus data" > condition. I suspect that we will soon be converting that to a FATAL > error[1], and that'll need to be done in both places. You mean for the two callers of XLogReadRecordAlloc(), even for the case where !allow_oversized? Using a FATAL on non-FRONTEND would be the quickest fix, indeed, but there are argument for standbys where we could let these continue, as well. That would be an improvement over the always-FATAL on OOM, of course. > 2. In this version of the commit message I said we'd only back-patch > to 15 for now. After sleeping on this for a week, I realised that the > reason I keep vacillating on that point is that I am not sure what > your plan is for the malloc-failure-means-end-of-wal policy ([1], > ancient code from 0ffe11abd3a). If we're going to fix that in master > only but let sleeping dogs lie in the back-branches, then it becomes > less important to go back further than 15 with THIS patch. For HEAD, my plan was to give more control to the callers of the WAL reader, which is not something that could happen in back-branches because it requires a few structural changes in the reporting the reader is able to do. That's the standby vs crash-recovery behavior, where we can make the startup process not FATAL all the time because it should just loop forever if it cannot process a record. It does not fix the root issue discussed here, of course, but it make the OOM handling more friendly in some replay cases. > But if you > want to be able to distinguish garbage from out-of-memory, and thereby > end-of-wal from a FATAL please-insert-more-RAM condition, I think > you'd really need this industrial strength validation in all affected > branches, and I'd have more work to do, right? The weak validation we > are fixing here is the *real* underlying problem going back many > years, right? Getting the same validation checks for all the branches would be nice. FATAL-ing on OOM to force recovery to happen again is a better option than assuming that it is the end of recovery. I am OK to provide patches for all the branches for the sake of this thread, if that helps. Switching to a hard FATAL on OOM for the WAL reader in the backend is backpatchable, but I'd rather consider that on a different thread once the better checks for the record header are in place. > I also wondered about strengthening the validation of various things > like redo begin/end LSNs etc in these tests. But we can always > continue to improve all this later... Agreed. -- Michael --OLV1rviX9OPloDkZ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAABCgAdFiEEG72nH6vTowiyblFKnvQgOdbyQH0FAmT1VPQACgkQnvQgOdby QH33SA/+PVTO0PBGFpipRfD8R4bke2ro6WXprirJqxNBCgAEnS6X9ffBUsykAVfN I2YOi6Doy7YvWJ6A/OVcBZXpOH2dreH3iZUV7QgjNH2/jU6/AKd2KduhHu/oggHi TWouMI9KCYJ8NPUhCoH3Xt+k2rGe/5ng+MDaa974eoo7kel44BRXbG7w3gCbkabP YAjH7+jNbPMvrhENl/kXq62++/Ir1JHZvlvECBaqZiaTIdU2CyfHMq/JJ11lVAfH fPyuEngUOS9bafVxr0262ZEi2ndL+weAPtXZ5W1iqyu74EKiNGSRqhvHmDLVM1Or Gp3bu8zQL3MMROq8sW0FOx0XROM0mFvDQxPYRzSRPAKCnTy9OF/+3ANvrD1O5A3Z oJ6spvenHR0UBKenP1haRTzatyM6CYX9wCfN5KXcP/eD54/MMShnjDGw80qU5WDm kkd47VXVu7Ed6qkW5FigOUniMA+Y5Nb8T2EL7zHkzI0pyhXLzj6q104Uhdzs3ZMT Zajpiy7ichZcsaEd/Vr+/dQcVJq37oEl/0vtg2h/haVPSLFj0eMUexVjM7r8rbe+ Ydle4Y8dxZU4XWXK/b4Jzuzbd6hnGEieLOCFLYwl8F+xfikGvEK9Ix0TFlrmzMzq p3KB+Jh04luO7GK5bYF0YqPlwD0aRJqRYANCvN4h/cm1CAfguBU= =Xixe -----END PGP SIGNATURE----- --OLV1rviX9OPloDkZ--