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 1pIKwc-0001cN-O8 for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2023 02:46:27 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pIKwa-00042S-Id for pgsql-hackers@arkaria.postgresql.org; Thu, 19 Jan 2023 02:46:24 +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 1pIKwZ-00041W-NT for pgsql-hackers@lists.postgresql.org; Thu, 19 Jan 2023 02:46:24 +0000 Received: from out3-smtp.messagingengine.com ([66.111.4.27]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pIKwW-0006AX-T5 for pgsql-hackers@postgresql.org; Thu, 19 Jan 2023 02:46:22 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 57B9E5C00E0; Wed, 18 Jan 2023 21:46:19 -0500 (EST) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Wed, 18 Jan 2023 21:46:19 -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=fm3; t=1674096379; x=1674182779; bh=idRSBRncCq niksoHZrIJdun99beddW3OoLhNLRF6XH8=; b=KCV3xZ89Yzn4Jm+wupEJBivAcP HaPkHC74T69OPgLJQtNf3MWkD7JiAwJreOs8oUr72BIaxw6ej+puUWe0xNbuu8Yd NRxbjwBUdWZl7hXuwGPa3KNVHXcDIbrrV8jnn0JrG2kFxW2BnviARdh0hWPIsquQ ymMtdubciRnHZ5vVy6vTSL8Nf1MR80xYkM5QcxCwW+sRrngQDT5JjcyKPPMKwaxD 5BMq3u+euNuAAvzubD6N3NSirkUPnzoz8FFICqQ0XGZ5ZO2c7PW/fRdjJkYRtdIQ pH78NdxTVDm2tzBdnRrkGcHbYcuoeUrEQdILh2Wp5P9SwOqu8u1N9Jogtf6w== 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= fm3; t=1674096379; x=1674182779; bh=idRSBRncCqniksoHZrIJdun99bed dW3OoLhNLRF6XH8=; b=jjMFftb7HwGFVSa+F13FuB6nEfM8IWU0tDhhfTaLswBS WpjDQVFbbYj+rXHmGtjxItCnfK9sBLovveuugp99hCClcos0/VzLdW9ri/d7Av2d 0T8VcRGrdO6tH2987V4Zh8a9BmZJxVV+CzSz2soAB3A0sJoc2s18N7PlVD6M3OxC 3Baiflr4f5sRJobW7umv7PESHxzLcl0qaL0rPPIEK84LB6qeAvbrRKnKBVO4l7uG jBFAEV9OAt07Gl7yrRDihfpfRHEaHWhYhCvvAWYmm09H+WhSzmXmJy6O1Ea3CgA1 ckRAynab81CM1qn3RsEWwYNm/GjMoGiwVVdU9kX3Qg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedruddtledghedtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesthdtredttddtvdenucfhrhhomheptehnughr vghsucfhrhgvuhhnugcuoegrnhgurhgvshesrghnrghrrgiivghlrdguvgeqnecuggftrf grthhtvghrnhepvdfffeevhfetveffgeeiteefhfdtvdffjeevhfeuteegleduheetvedu ieettddunecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomh eprghnughrvghssegrnhgrrhgriigvlhdruggv X-ME-Proxy: Feedback-ID: id4a34324:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 18 Jan 2023 21:46:18 -0500 (EST) Date: Wed, 18 Jan 2023 18:46:17 -0800 From: Andres Freund To: "Drouvot, Bertrand" Cc: Robert Haas , Thomas Munro , Alvaro Herrera , Ibrar Ahmed , Amit Khandekar , fabriziomello@gmail.com, tushar , Rahila Syed , pgsql-hackers Subject: Re: Minimal logical decoding on standbys Message-ID: <20230119024617.jzsgpcrgjdc6ysge@awork3.anarazel.de> References: <1f2ad9fd-53ff-74cc-a602-72d45423bcab@gmail.com> <05c0c4f3-82eb-bc6d-c876-5a265c05927b@gmail.com> <20230106034036.2m4qnn7ep7b5ipet@awork3.anarazel.de> <490206c5-bcde-e558-628a-dc67dae4d439@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <490206c5-bcde-e558-628a-dc67dae4d439@gmail.com> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Hi, On 2023-01-18 11:24:19 +0100, Drouvot, Bertrand wrote: > On 1/6/23 4:40 AM, Andres Freund wrote: > > Hm, that's quite expensive. Perhaps worth adding a C helper that can do that > > for us instead? This will likely also be needed in real applications after all. > > > > Not sure I got it. What the C helper would be supposed to do? Call LogStandbySnapshot(). > With a reload in place in my testing, now I notice that the catalog_xmin > is updated on the primary physical slot after logical slots invalidation > when reloading hot_standby_feedback from "off" to "on". > > This is not the case after a re-start (aka catalog_xmin is NULL). > > I think a re-start and reload should produce identical behavior on > the primary physical slot. If so, I'm tempted to think that the catalog_xmin > should be updated in case of a re-start too (even if all the logical slots are invalidated) > because the slots are not dropped yet. What do you think? I can't quite follow the steps leading up to the difference. Could you list them in a bit more detail? > > Can we do something cheaper than rewriting the entire database? Seems > > rewriting a single table ought to be sufficient? > > > > While implementing the test at the table level I discovered that It looks like there is no guarantee that say a "vacuum full pg_class;" would > produce a conflict. I assume that's mostly when there weren't any removal > Indeed, from what I can see in my testing it could generate a XLOG_HEAP2_PRUNE with snapshotConflictHorizon to 0: > > "rmgr: Heap2 len (rec/tot): 107/ 107, tx: 848, lsn: 0/03B98B30, prev 0/03B98AF0, desc: PRUNE snapshotConflictHorizon 0" > > > Having a snapshotConflictHorizon to zero leads to ResolveRecoveryConflictWithSnapshot() simply returning > without any conflict handling. That doesn't have to mean anything bad. Some row versions can be removed without creating a conflict. See HeapTupleHeaderAdvanceConflictHorizon(), specifically * Ignore tuples inserted by an aborted transaction or if the tuple was * updated/deleted by the inserting transaction. > It does look like that in the standby decoding case that's not the right behavior (and that the xid that generated the PRUNING should be used instead) > , what do you think? That'd not work, because that'll be typically newer than the catalog_xmin. So we'd start invalidating things left and right, despite not needing to. Did you see anything else around this making you suspicious? > > > +################################################## > > > +# Test standby promotion and logical decoding behavior > > > +# after the standby gets promoted. > > > +################################################## > > > + > > > > I think this also should test the streaming / walsender case. > > > > Do you mean cascading standby? I mean a logical walsender that starts on a standby and continues across promotion of the standby. Greetings, Andres Freund