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 1mJ381-0006ma-J2 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Aug 2021 00:20:21 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1mJ380-0006tG-E3 for pgsql-hackers@arkaria.postgresql.org; Thu, 26 Aug 2021 00:20:20 +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 1mJ37z-0006t8-LL for pgsql-hackers@lists.postgresql.org; Thu, 26 Aug 2021 00:20:20 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by magus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mJ37s-0005fs-83 for pgsql-hackers@lists.postgresql.org; Thu, 26 Aug 2021 00:20:18 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 4886E5C0160; Wed, 25 Aug 2021 20:20:09 -0400 (EDT) Received: from mailfrontend2 ([10.202.2.163]) by compute6.internal (MEProxy); Wed, 25 Aug 2021 20:20:09 -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= fm3; bh=kTZJylf5+I4snaFaUaxetJytzjLhFt2kAczJVFdXITs=; b=KVOVZstd OKS3+zPKjb+T2QWZRhyxcxZI9D1Q8o4lVXPVdxrsBTbxtMKS0p78JWLn/IELxYS/ 4Dqbc/OfTDztVljeB5fERJIT/fWj9mEtEYofSIY5M327kf5lllBSpwcK0B/ydFTz jOR01IuNpP2BUztg8GXxX5iU+blfTlb1IZi1BGL1M25eExUnc9zlO2YnrxaJ5olm j4AQ5yRRCsj2518oOAEdMdnr4hcvO9/gY7/PKXVbbt/604b4QgvT3Wh9u2rsZPAL QHLXs4TYm9oPShOCQYoSlfx2tUQO4qhDPFUF3LkguVbmW2ZT1LtKsLjjlciVfQe5 k5a1gmrGeo25fw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvtddruddutddgfeefucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvffukfggtggugfgjsehmkeerredttdejnecuhfhrohhmpedfrghlvhhh vghrrhgvsegrlhhvhhdrnhhoqdhiphdrohhrghdfuceorghlvhhhvghrrhgvsegrlhhvhh drnhhoqdhiphdrohhrgheqnecuggftrfgrthhtvghrnhepkedutddvffeijeefteefuddu kefhvdevudejlefhieeikedvhefgvdeugeffleeinecuffhomhgrihhnpegvnhhtvghrph hrihhsvggusgdrtghomhenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgr ihhlfhhrohhmpegrlhhvhhgvrhhrvgesrghlvhhhrdhnohdqihhprdhorhhg X-ME-Proxy: Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 25 Aug 2021 20:20:07 -0400 (EDT) Received: by perhan.alvh.no-ip.org (Postfix, from userid 1000) id 4B8D42A06AD; Wed, 25 Aug 2021 20:20:04 -0400 (-04) Date: Wed, 25 Aug 2021 20:20:04 -0400 From: "alvherre@alvh.no-ip.org" To: Jakub Wartak Cc: "Bossart, Nathan" , Kyotaro Horiguchi , "pgsql-hackers@lists.postgresql.org" , "mengjuan.cmj@alibaba-inc.com" Subject: Re: prevent immature WAL streaming Message-ID: <202108260020.cjxmmc2m7iws@alvherre.pgsql> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="3yksj3c27rk3whvb" Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202108252329.oqhdllz2iq73@alvherre.pgsql> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --3yksj3c27rk3whvb Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit BTW while going about testing this, I noticed that we forbid pg_walfile_name() while in recovery. That restriction was added by commit 370f770c15a4 because ThisTimeLineID was not set correctly during recovery. That was supposed to be fixed by commit 1148e22a82ed, so I thought that it should be possible to remove the restriction. However, I did that per the attached patch, but was quickly disappointed because ThisTimeLineID seems to remain zero in a standby for reasons that I didn't investigate. -- Álvaro Herrera 39°49'30"S 73°17'W — https://www.EnterpriseDB.com/ "The problem with the facetime model is not just that it's demoralizing, but that the people pretending to work interrupt the ones actually working." (Paul Graham) --3yksj3c27rk3whvb Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename="0001-Don-t-forbid-pg_walfile_name-in-recovery-mode.patch" From 1b57e504b9a7eeddf2d99e615f21c5aec042a908 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 25 Aug 2021 19:55:43 -0400 Subject: [PATCH] Don't forbid pg_walfile_name in recovery mode --- src/backend/access/transam/xlogfuncs.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/backend/access/transam/xlogfuncs.c b/src/backend/access/transam/xlogfuncs.c index b98deb72ec..99b22d0b30 100644 --- a/src/backend/access/transam/xlogfuncs.c +++ b/src/backend/access/transam/xlogfuncs.c @@ -503,13 +503,6 @@ pg_walfile_name(PG_FUNCTION_ARGS) XLogRecPtr locationpoint = PG_GETARG_LSN(0); char xlogfilename[MAXFNAMELEN]; - if (RecoveryInProgress()) - ereport(ERROR, - (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE), - errmsg("recovery is in progress"), - errhint("%s cannot be executed during recovery.", - "pg_walfile_name()"))); - XLByteToPrevSeg(locationpoint, xlogsegno, wal_segment_size); XLogFileName(xlogfilename, ThisTimeLineID, xlogsegno, wal_segment_size); -- 2.30.2 --3yksj3c27rk3whvb--