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 1v9zjG-00BqmR-Oi for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Oct 2025 05:43:46 +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 1v9zjE-0070XV-LT for pgsql-hackers@arkaria.postgresql.org; Sat, 18 Oct 2025 05:43:43 +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 1v9zjD-0070XK-Q6 for pgsql-hackers@lists.postgresql.org; Sat, 18 Oct 2025 05:43:43 +0000 Received: from fhigh-a1-smtp.messagingengine.com ([103.168.172.152]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1v9zj9-002qdf-17 for pgsql-hackers@postgresql.org; Sat, 18 Oct 2025 05:43:42 +0000 Received: from phl-compute-04.internal (phl-compute-04.internal [10.202.2.44]) by mailfhigh.phl.internal (Postfix) with ESMTP id AE0E01400116; Sat, 18 Oct 2025 01:43:36 -0400 (EDT) Received: from phl-imap-03 ([10.202.2.93]) by phl-compute-04.internal (MEProxy); Sat, 18 Oct 2025 01:43:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=compiler.org; h= cc: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=fm2; t=1760766216; x=1760852616; bh=xCCDq8ClDdhsH6/FiM+c+miJttVLuZXBUMr41I9VLZQ=; b= JS3mp4kSfYfC2vKbjnQ0p4lqcr4q3oThzbsuEw6S7Ita//l5rb0uTKr2ZFvVmQCc K0bOCedkGe/JFRbqyOZd03eyaddiWCX8RNIhrH4DHgNBDVmP5WIGCPxiRmNq5Jvh W0h1kgVksZdMuWXjK7JmSiOh1VFRZFSnFI0YxsIWlrnrwILN+JHBYmCCsczvNSmY LLsbFZOM2Q1XKcbUrKBxEnM5cXt7ZmPFxVp4hXY4m8qXH/ycHWd+2UI/YHzfAzXb uV6PUHqgActlcKViJWJUl3Tg/acPnoEWC23hQCzF0Dz/uIWNe7abyrJFsfDtazVk VGk7lQcrGQ55kQ/jdxdUvw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc: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=fm2; t=1760766216; x= 1760852616; bh=xCCDq8ClDdhsH6/FiM+c+miJttVLuZXBUMr41I9VLZQ=; b=S cTsmHKkwacCc5homEh161IzoKDJemfOSqRJsDgfCff9E4UUYFQrPOL2SZyTG1Soo uf82UPHa96Y2gPq9hnqWQIq8aK283di/Jb5lLAyuhFBMRgxOsWYvs7s8rod6GT5U 38vnURGBf2LifhHxgV1WDICZHkOI3IE/ZJgFUzzV5NKyggYLJxT+F2TMf9lTYKm3 kknQyMWdnXuIPF9jtpvrE8lVUtvbeS2SxHcMhLgViddfo9dIudm7MEKLQzHgbXnA n4kx7t6ByuDc2JLnxaTgQTmqOCXPUVv9uYMKIU9laXuMBNV/yG0EapxGTMTHLhTq lx0tz95RiQBYPXP+Yts2w== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeeffedrtdeggddufeduvdegucetufdoteggodetrf dotffvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfurfetoffkrfgpnffqhgenuceu rghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujf gurhepofggfffhvfevkfgjfhfutgfgsehtqhertdertdejnecuhfhrohhmpedflfhovghl ucflrggtohgsshhonhdfuceojhhovghlsegtohhmphhilhgvrhdrohhrgheqnecuggftrf grthhtvghrnhepgfdtffefjeegkeegkeehtddvhfffiefgffeugfelffdtteeihedtkefh jeetvdelnecuffhomhgrihhnpehpohhsthhgrhgvshhqlhdrohhrghenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjohgvlhestghomhhpihhl vghrrdhorhhgpdhnsggprhgtphhtthhopedutddpmhhouggvpehsmhhtphhouhhtpdhrtg hpthhtohepfegurghnihhsshhimhhosehgmhgrihhlrdgtohhmpdhrtghpthhtoheprghl vgigrghnughrrgdrfigrnhhgrdhoshhssehgmhgrihhlrdgtohhmpdhrtghpthhtoheprg hrshgvnhhihidrmhhukhhhihhnrdguvghvsehgmhgrihhlrdgtohhmpdhrtghpthhtohep mhgrthhhvghushhsshhilhhvleejsehgmhgrihhlrdgtohhmpdhrtghpthhtoheprhhish hhuhdrphhoshhtghhrvghssehgmhgrihhlrdgtohhmpdhrtghpthhtohepshgrfigruggr rdhmshhhkhesghhmrghilhdrtghomhdprhgtphhtthhopegrlhhvhhgvrhhrvgeskhhurh hilhgvmhhurdguvgdprhgtphhtthhopeihrdhsohhkohhlohhvsehpohhsthhgrhgvshhp rhhordhruhdprhgtphhtthhopehpghhsqhhlqdhhrggtkhgvrhhssehpohhsthhgrhgvsh hqlhdrohhrgh X-ME-Proxy: Feedback-ID: ic6394509:Fastmail Received: by mailuser.phl.internal (Postfix, from userid 501) id B5D9218E0054; Sat, 18 Oct 2025 01:43:35 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface MIME-Version: 1.0 X-ThreadId: AYKEI1WM5q2o Date: Sat, 18 Oct 2025 07:43:15 +0200 From: "Joel Jacobson" To: "Arseniy Mukhin" , =?UTF-8?Q?=C3=81lvaro_Herrera?= Cc: "Matheus Alcantara" , "Masahiko Sawada" , "Rishu Bagga" , "Yura Sokolov" , "Daniil Davydov" <3danissimo@gmail.com>, "Alexandra Wang" , pgsql-hackers , "Tom Lane" Message-Id: <01fbde80-0ff6-4bf4-b942-cd60b76380d1@app.fastmail.com> In-Reply-To: References: <202510171347.twmkbitfsgfh@alvherre.pgsql> Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri, Oct 17, 2025, at 22:50, Arseniy Mukhin wrote: > On Fri, Oct 17, 2025 at 7:31=E2=80=AFPM =C3=81lvaro Herrera wrote: >> >> I have the impression that this thread has lost focus on the idea of >> producing a backpatchable bugfix. The last proposed patch has a lot = of >> new mechanism that doesn't seem suitable for backpatch. I could be >> wrong of course. >> > > Oops, I guess the TAP test that I added in the last version and that > uses injection points is one of those things. PFA the new version > without it. I also noticed that CheckSharedObjectLockedByMe() which > was introduced in one of previous versions is unused, so I removed it > too. What a funny coincidence that the approach in this patch, has one similarity with the "Direct advancement" approach in the patch in the "Optimize LISTEN/NOTIFY" [1]=C2=A0thread, namely that we're both interested in QUEUE_HEAD before/after we push the notifications into the queue, in PreCommit_Notify(). It looks to me like our new data structures are Interchangeable, so I guess we probably want both patches to eventually settle on one and the same? The differences I note between our queue head before/after code are: - In this patch, you are palloc'ing a struct with two fields. In [1], we're using two separate static QueuePosition variables. - In this patch, you are taking/releasing a shared lock before/after the loop to read QUEUE_HEAD and set previousHead/head. In [1], we avoid the need of the shared lock, by doing the reads within the existing exclusive lock inside the loop, but instead therefore need a firstIteration bool, to know which is the first iteration, and need to overwrite the after-var in each iteration. I don't think the noted differences above matter, both seems fine. Another thing I noticed in your patch that made me wonder, is the naming of the new AsyncQueueEntry bool field, which is given the name "committed". I think this name is not entirely faithful, since when set to true, the entry has not been committed yet. How about negating the meaning of this boolean field? To instead indicate when the entry has been rollbacked. Then, it would clearly communicate just that. Maybe naming it something like "rollbacked" or "aborted"? /Joel [1] https://www.postgresql.org/message-id/flat/6899c044-4a82-49be-8117-e= 6f669765f7e%40app.fastmail.com