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 1vE5L4-004UOU-Nq for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Oct 2025 12:31:42 +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 1vE5K3-000ssd-GK for pgsql-hackers@arkaria.postgresql.org; Wed, 29 Oct 2025 12:30:38 +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 1vE5K2-000ssU-RP for pgsql-hackers@lists.postgresql.org; Wed, 29 Oct 2025 12:30:38 +0000 Received: from fhigh-a6-smtp.messagingengine.com ([103.168.172.157]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vE5Jz-004ss7-0W for pgsql-hackers@postgresql.org; Wed, 29 Oct 2025 12:30:37 +0000 Received: from phl-compute-05.internal (phl-compute-05.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id F2C0A1400219; Wed, 29 Oct 2025 08:30:32 -0400 (EDT) Received: from phl-imap-03 ([10.202.2.93]) by phl-compute-05.internal (MEProxy); Wed, 29 Oct 2025 08:30:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compiler.org; h= cc:content-transfer-encoding:content-type:content-type:date:date :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1761741032; x=1761827432; bh=uXnOfVkdmcc2w2vgj2N3mcm/YHfqWE6v7VTgAPQTCyc=; b= gxjRVp/Mt4WAmGStZyITXW4vICp56vQ1GZpqWI5mwBQ1N5KFqOGFhRVCxKC/Bepr yi7ko/5ArvO6k829rtP4frhYyC43CbOSoB9mB5kmTwE+ZEJk5/J6CUVDoRlLgeOs /LpyKTAgnfxA9uio7SgbV1Q/Tbru3/V61PnBGRFT3+hsOd0Dd4di2h5zcWRnDgBD LS1/LzWyxkH203T+TLTYpAu5rwkpOqzJMJnlO0eR88f66jd5Epl9DW67QXP8jnKn 705TgGMM4fmOZN6NG+5UM8ezF8TNQDlPWpTs3k0E+byJbfYAm8njcEHfdeCPGYFv dm8lZLR56sTTCSJ3uATLRw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding: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:subject:subject:to:to:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; t=1761741032; x=1761827432; bh=u XnOfVkdmcc2w2vgj2N3mcm/YHfqWE6v7VTgAPQTCyc=; b=cGu+EW5ftg6VJkeSn NdIP6Uihg/A5JDYn1OyL/oVwiaIwjEZ2qaqXEqlICLrAa3leIC5Uz5lC297nZIG5 YtkGjfU+2cxmPuNZaKrr4Zg/sgO/ws40uEetAEXx3nAub3+VE9g+JjAZW4UfStyj JkIAMXw8jlnBDTcGHHvY9dHrncmIEWHcopg59tSVr1A2rUrebZ7PbFPbiUQ4awdZ zNZwqNe4ZM6M8UulRYnJ3wkb0XWmSbCujSWFFaauFrEY/dBibKnROOigp40dYQtF hVUXJtS/hFByXD41v477JVh9MRnMsGyenq7Rxg+Gtu3RmtfSeKkqygX7UhaK37RM ViCmQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggdduieefjeefucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvffkjghfufgtgfesthejredtredttdenucfhrhhomhepfdflohgvlhcu lfgrtghosghsohhnfdcuoehjohgvlhestghomhhpihhlvghrrdhorhhgqeenucggtffrrg htthgvrhhnpeevlefftdeiudfgvdfgffdtvdeiveelteeitefgtedtffejtdejfefflefh leffieenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe hjohgvlhestghomhhpihhlvghrrdhorhhgpdhnsggprhgtphhtthhopedvpdhmohguvgep shhmthhpohhuthdprhgtphhtthhopehhlhhinhhnrghkrgesihhkihdrfhhipdhrtghpth htohepphhgshhqlhdqhhgrtghkvghrshesphhoshhtghhrvghsqhhlrdhorhhg X-ME-Proxy: Feedback-ID: ic6394509:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id 6B10E18E0069; Wed, 29 Oct 2025 08:30:32 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: AYKEI1WM5q2o Date: Wed, 29 Oct 2025 13:30:12 +0100 From: "Joel Jacobson" To: "Heikki Linnakangas" , pgsql-hackers Message-Id: <2297af80-dd5d-4fcc-815b-75bd64b00bf9@app.fastmail.com> In-Reply-To: <769bbdba-f86f-44ad-abad-f6ea4f74e3f2@iki.fi> References: <202510221548.tgggefdrlpo3@alvherre.pgsql> <149c402d-54c9-48dd-a730-2f5b958f2129@app.fastmail.com> <769bbdba-f86f-44ad-abad-f6ea4f74e3f2@iki.fi> Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue Content-Type: text/plain Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Oct 29, 2025, at 12:40, Heikki Linnakangas wrote: > On 25/10/2025 21:01, Joel Jacobson wrote: >> I also want to share a new idea that Heikki Linnakangas came up with >> during PgConf25 in Riga. >> >> The idea is basically to scan the notification queue from tail to head, >> and update xids that precedes newFrozenXid, to either >> FrozenTransactionId if committed, or InvalidTransactionId if not. >> >> I've implemented this by adding a new extern function >> AsyncNotifyFreezeXids to async.h, called from vac_update_datfrozenxid. >> >> This way, we don't need to hold back the advancement of newFrozenXid in >> vac_update_datfrozenxid. >> >> Attempt of implementing Heikki's idea: >> - async_notify_freeze_xids.txt > > Thanks! Thanks for the idea! >> This idea has the benefit of never holding back newFrozenXid, >> however, I see some problems with it: >> >> - If there is a bug in the code, we could accidentally overwrite >> xid values we didn't intend to overwrite, and maybe we would never >> find out that we did. >> >> - We wouldn't know for sure that we've understood the cause of >> this bug. >> >> With v12-vacuum_notify_queue_cleanup, we instead have the downside of >> possibly holding back newFrozenXid, but with the advantage of giving us >> higher confidence in that we've correctly identified the cause of the >> bug. > > Meh. Robustness is good and all, and in heap tuples we don't overwrite > the xmin/xmax but just set a FROZEN flag, precisely so that we preserve > evidence if something goes wrong. But I can't get too worked up about > that for the async notification queue. Having slept on this for some days, I'm less worried about this approach. I like the simplicity of it, and that we don't bolt on complexity to another subsystem, just for the sake of improved debugging capabilities of a different subsystem. I think a different way of looking at this, is that we wouldn't conceal a bug in async, but rather we would let vacuum do part of its job, of checking the commit status of the xids, when needed, and be okay with that split responsibility. If we can prove that the optimizations we're working on, will render that new code unnecessary, then I guess we can just remove it. > That said, we could add COMMITTED/INVALID hint bits to AsyncQueueEntry, > similar to heap tuples, and set the hint bit instead of replacing the > original xid. That might be good for performance too: If the first > backend to call TransactionIdDidCommit() on an AsyncQueueEntry would set > the hint bit, that would save the effort for other listening backends. Interesting, sounds like a really promising approach. /Joel