Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mai2y-0000mP-HV for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Oct 2021 17:28:08 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mai2x-0004oi-As for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Oct 2021 17:28:07 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mai2x-0004lm-2o for pgsql-hackers@lists.postgresql.org; Wed, 13 Oct 2021 17:28:07 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mai2u-0001lp-EO for pgsql-hackers@lists.postgresql.org; Wed, 13 Oct 2021 17:28:06 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 237465C01CF; Wed, 13 Oct 2021 13:28:03 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 13 Oct 2021 13:28:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:subject:to :x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; bh=+LWw4/ZzT4BUatvNiGBphKBKVQFdHGfvG6RY5B0PJ74=; b=LVbdpEgh BYmpIhOCeaoyEE0A0J5K0eiwSqOXGK2aw/bP2SEHKACNOF2GppiVVjJIRVKUjGGt 8upS0I/hI6Pd3lw18nZ0DKP0x94wG5/Nhjx+qiYPZAAgWr0MYDpTcxGAkNJ7jirq 7BUZMZ/VYhHlq/0FXMJ6LX3ScTT5rgDia1mPuYYr6yNN7H3uOduhIHJIN2jrSZ7X ghc5XA+8qiU54hzEJx85k0tp3b9GscrpV1k8Pwe1C3I7XQB/kWOIaPXV/u3K3Lrx M64LUGKLiO4Z4cECfg6g2lbjAUUqcPwlh4uNM6OUF7pTNe83Wik4poKD916geLtG Dj8bIDeHkPR/xw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddrvddutddguddutdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpeffhffvuffkgggtugfgjgesthekredttddtjeenucfhrhhomheptehlvhgr rhhoucfjvghrrhgvrhgruceorghlvhhhvghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrgh eqnecuggftrfgrthhtvghrnhepudejveejffejveduudetvdekieeuiedtvdeileefkeev jedufeeguedvjefhueelnecuffhomhgrihhnpegvnhhtvghrphhrihhsvggusgdrtghomh enucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpegrlhhv hhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 13 Oct 2021 13:28:01 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id EB3132A06EC; Wed, 13 Oct 2021 14:27:58 -0300 (-03) Date: Wed, 13 Oct 2021 14:27:58 -0300 From: Alvaro Herrera To: Amul Sul Cc: "Bossart, Nathan" , "Jakub.Wartak@tomtom.com" , Kyotaro Horiguchi , Ryo Matsumura , "andres@anarazel.de" , "masao.fujii@oss.nttdata.com" , "mengjuan.cmj@alibaba-inc.com" , "pgsql-hackers@lists.postgresql.org" Subject: Re: prevent immature WAL streaming Message-ID: <202110131727.7oimptrkzkiv@alvherre.pgsql> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 2021-Oct-13, Amul Sul wrote: > I have one more question, regarding the need for other global > variables i.e. abortedRecPtr. (Sorry for coming back after so long.) > > Instead of abortedRecPtr point, isn't enough to write > overwrite-contrecord at XLogCtl->lastReplayedEndRecPtr? I think both > are pointing to the same location then can't we use > lastReplayedEndRecPtr instead of abortedRecPtr to write > overwrite-contrecord and remove need of extra global variable, like > attached? I'm a bit fuzzy on the difference "the end+1" and "the start of the next record". Are they always the same? We do have XLogRecPtrToBytePos() and XLogBytePosToEndRecPtr() to convert unadorned XLogRecPtr values to "usable byte positions", which suggests to me that the proposed patch may fail if end+1 is a page or segment boundary. The other difference is that abortedRecPtr is set if we fail to read a record, but XLogCtl->lastReplayedEndRecPtr is set even if we read the record successfully. So you'd have need a bool flag that the overwrite contrecord record needs to be written. Your patch is using the fact that missingContrecPtr is non-invalid as such a flag ... I can't see anything wrong with that. So maybe your patch is okay in this aspect. > You might wonder why I am so concerned about the global variable. The > reason is that I am working on another thread[1] where we are trying > to club all the WAL write operations that happen at the end of > StartupXLOG into a separate function. In the future, we might want to > allow executing this function from other processes (e.g. > Checkpointer). For that, we need to remove the dependency of those WAL > write operations having on the global variables which are mostly valid > in the startup process. Seems a fine goal. -- Álvaro Herrera PostgreSQL Developer — https://www.EnterpriseDB.com/