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 1pV09z-0006Zh-Mn for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Feb 2023 01:12:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pV09y-00085W-EN for pgsql-hackers@arkaria.postgresql.org; Thu, 23 Feb 2023 01:12:34 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pV09y-00085N-4l for pgsql-hackers@lists.postgresql.org; Thu, 23 Feb 2023 01:12:34 +0000 Received: from wout4-smtp.messagingengine.com ([64.147.123.20]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pV09v-0000AE-V9 for pgsql-hackers@postgresql.org; Thu, 23 Feb 2023 01:12:33 +0000 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id 56ABB3200913; Wed, 22 Feb 2023 20:12:30 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Wed, 22 Feb 2023 20:12:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=anarazel.de; h= cc:cc: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=1677114749; x=1677201149; bh=A68brGTddJ WFBpNKzCHfrvfKcnE98nHRoSXPKsacnuM=; b=dDyCjiPdnZZcx/QEZS9sUjBGfT CVj9y8nzQ8PJOSQOcilUv7gbfZ/AUd+MQSV3VPKfQ0hzBOC3EtsuZ5RmUVanArXF 2NiXBFQNZOKcjUcCmJplfLBshN5HUUByoktZS7eJXds0bZkD2iLXj5a8qpDqzvFz o7F6Fiq+ytk507LVm8Kc2SZbeDZzUDAtM1XKkGt/b61UWUVAppV1QrbqYFcBSN1s VRjJUH5BSUStYoQ7A+hw3igHB7nipezwn6G3fcYfR25AIs4wC1zC6T0z7BuLkdHQ x9NwIP118r0NJ+sU+476RGiE8eucCODfXRK/hTYr6VL/3Nt3Y2DjakWL+xNw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc: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=1677114749; x=1677201149; bh=A68brGTddJWFBpNKzCHfrvfKcnE9 8nHRoSXPKsacnuM=; b=mqBRuJ/88o7f3d/qfuo2z8AYw7yL1YMK9+J6VBjIcLfg gxHgLdNBR2oCs3RaOn70lTzg1DwUwvwwHmiw4tGCoaYQydqaSqQc9pEPLol14YNe 7oR1h4ge+5Wb1/gFSKnm2brav1s1wVg81nMTiuNnapzF4uGmU5gCqSRe5oQ49NQN 2SePl6cZCK19cMY7GeOoZLuQUnBlSHVrvdd6MD6QxQgeE9uo8jyNsBcarhgbvUII DSJz51Ykc+h9ajHyLQACqbWemIAoytHF09yv3GxIl5wk3nIm/G44AHsfpa9E2jK5 rBL0T7CMz6t6+8Ti6lAo1oct8osuNo12w9uBaAkUlg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrudektddgfeduucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 22 Feb 2023 20:12:29 -0500 (EST) Date: Wed, 22 Feb 2023 17:12:28 -0800 From: Andres Freund To: Heikki Linnakangas , Tom Lane Cc: vignesh C , pgsql-hackers@postgresql.org, Thomas Munro , Melanie Plageman , Yura Sokolov , Robert Haas Subject: Re: XLogReadBufferExtended() vs disconnected segments Message-ID: <20230223011228.3grh4sebgwtw2hln@awork3.anarazel.de> References: <20230223010147.32oir7sb66slqnjk@awork3.anarazel.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230223010147.32oir7sb66slqnjk@awork3.anarazel.de> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-02-22 17:01:47 -0800, Andres Freund wrote: > One way to to defend against this would be to make mdextend(), whenever it > extends into the last block of a segment, unlink the next segment - it can't > be a validly existing contents. But it seems scary to just unlink entire > segments. Another way might be for XLOG_SMGR_TRUNCATE record, as well as smgr unlinks in commit/abort records, to include not just the "target size", as we do today, but to also include the current size. I'm not sure that'd fix all potential issues, but it seems like it'd fix a lot of the more obvious issues, because it'd prevent scenarios like a base backup copying segment N, without copying N - 1, due to a concurrent truncate/drop, from causing harm. Due to the range being included in the WAL record, replay would know that N needs to be unlinked, even if smgrnblocks() thinks the relation is much smaller. Greetings, Andres Freund