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 1vBLbA-00FQRm-1v for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Oct 2025 23:16:59 +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 1vBLb8-00CQlg-QT for pgsql-hackers@arkaria.postgresql.org; Tue, 21 Oct 2025 23:16:57 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1vBLb8-00CQlW-Cc for pgsql-hackers@lists.postgresql.org; Tue, 21 Oct 2025 23:16:57 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1vBLb5-0033n4-20 for pgsql-hackers@postgresql.org; Tue, 21 Oct 2025 23:16:56 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-7a23208a0c2so2789467b3a.0 for ; Tue, 21 Oct 2025 16:16:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1761088615; x=1761693415; darn=postgresql.org; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=tilbPixcPzXgrPvc5bgFAw4pFifHnwCweRTtfp6n9mE=; b=UFt+pru2zblK8UBa0JGeTNB/GMgrwrjK7lfNZhyCeh9F16oI6+P5BrMDMvhAnIEh6Y 9V/4s21G/+Uo3Bk5qedBlRO9OoE9/ipefzhMTl8vWgscfNhR2PftFRGidup52B6JP0hC jn8Grboet7tvsai/GViAOLoI0wzbctEPj7Qj4CTKxg7ZMLYN2JLlZb4nltye1MRi8Jtt BB+ITbDyVZzC5Z5sYVKKsYhtirjkd3wDSktaTMXsnoA2ZoHLNqGBB+TwjQisYHg8ynl+ a+AFt1KxEaT1siT8f+AhO9IsfM8VnTsuASOPa6wQizwro39j6MpImcVn4xVyt25fLVEK c66Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1761088615; x=1761693415; h=in-reply-to:references:subject:cc:to:from:message-id:date :content-transfer-encoding:mime-version:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=tilbPixcPzXgrPvc5bgFAw4pFifHnwCweRTtfp6n9mE=; b=OR8ljVdLjYWoX13osFZexsjRwnolpaf7+HJL+8Ul0rMTLznIQQ5jTd7sYg22jX3W9S UBVYxNC3OFGYLq5xlZKwuM29tfLv5NlBTm05mv41+QujnvDxKfjjZ4oOwxj4TGwK+oZx /H+VaoTfoSr0VxaidRMbxMNY8jXGf0buePoSC8trzaP3pbWnwKacZ6S7jZwrYckEuY2X ZY7IkRwrZ4Zhly8WUur6UTr7eyjRlKbWTYLS8IUFxS2WddxDV8/HoDpy1hW00is45WSB xF1txoF8uNczH8y6TsALQwi1Vz76RJSya090qS5vV1C3TsQkDxJ7CwiKXquDnq328PEe pV0w== X-Forwarded-Encrypted: i=1; AJvYcCXYHciMABgyIW7czWTQV9VLQdCPcjX7voyAF9S5frK5OZda68uSWghEPk3JBeLgQnqDKyx6DqNt17jBa7Je@postgresql.org X-Gm-Message-State: AOJu0YyehUh0F7i5cR+VazeOtJC6WfO1DvynE1Zpiprx+NI0KZ0kUUkv EsSkocn6h7cNlKsCKLeipdVzAvZ6GCODi3imi8znwWdyn5WwRdi6IUE8 X-Gm-Gg: ASbGncviOrDeBujXlxU67BtfKn5lfVWxfUDdfrjavrUMYtA0QJpN8cmXWfu75Eci0TR XwjvpOybCawzeNOiwgS4V3nV9+BHwlhB9ehkrqH4iDYhq7rdWWaW8sH7s4Ey+E92A8nD1FLUbMK FXnWZFplXAKtHf0nMoDdmTQCXp+UUTboaKc5R8XS3JPUeK0WvMn8lDrhbB4ZQUzJOqJefiZj51B vZdi6CtfmmDodelpfdhYo2UBqcn3qgZUAxCpUIS9kIGytCFm01JiF/RRAvW/KjjwJDfW6SdC9H2 znR566v14qygFus44JMIbcQn80kjFIWe0t2Xl/BpJxM45Mfd7+zTtmAMR2uyU9QSDDyVzitvkSp eEnfadvqad/nf8zURzhxvD2LVmAXZlbTw+d/gBs6jYHBUmtWAs/2airmlV7MAHE5Hd4xGYGxGPr u2RIXYmJElRztXS6aCcHjClo91gwSvgaE5Gg== X-Google-Smtp-Source: AGHT+IHujbVYT/J0/9CaOgZrn5ZkdwCuwNqpqb5pR0uGzmmsxWimkYTP++G7jzQkqK8Akk36mm6RSg== X-Received: by 2002:a05:6a21:3382:b0:32b:7255:632 with SMTP id adf61e73a8af0-334a864a351mr26527405637.52.1761088614645; Tue, 21 Oct 2025 16:16:54 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:e4b1:4897:5aa2:cffe]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7a22ff15985sm12864353b3a.5.2025.10.21.16.16.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 21 Oct 2025 16:16:54 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Tue, 21 Oct 2025 20:16:49 -0300 Message-Id: From: "Matheus Alcantara" To: "Masahiko Sawada" , "Matheus Alcantara" Cc: =?utf-8?q?=C3=81lvaro_Herrera?= , "Joel Jacobson" , "Arseniy Mukhin" , "Rishu Bagga" , "Yura Sokolov" , "Daniil Davydov" <3danissimo@gmail.com>, "Alexandra Wang" , "pgsql-hackers" , "Tom Lane" Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue X-Mailer: aerc 0.21.0 References: <202510201414.56f2msqusjla@alvherre.pgsql> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On 21/10/25 18:42, Masahiko Sawada wrote: > On Mon, Oct 20, 2025 at 11:19=E2=80=AFAM Matheus Alcantara > wrote: >> >> On Mon Oct 20, 2025 at 11:18 AM -03, =C3=81lvaro Herrera wrote: >>> On 2025-Oct-20, Matheus Alcantara wrote: >>> >>>> This is similar to what was already proposed at [1]. This approach was >>>> abandoned because a notification on the queue may block datfrozenxid >>>> advance and clog truncation which can cause other issues for the users= [2]. >>> >>> Well, I think that this is the right solution for backpatching, and tha= t >>> you were wrong to abandon it. You can continue to design a better >>> mechanism for the master branch, but in old branches we cannot really d= o >>> all those things you're proposing to do. >>> >> I actually would prefer this approach TBH, but since this can cause >> other issues like transaction wraparound due to not consumed >> notifications we would need other mechanisms to prevent that and I'm not >> sure if users should expect this kind of behavior changes on minor >> version updates? >=20 > True, unconsumed notifications could cause transaction wraparound by > preventing datfrozenxid from advancing. However, this risk only > applies when users have long-term unconsumed notifications, which is > uncommon. That said, we should note that, as I mentioned > previously[1], a process can accumulate unconsumed notifications > simply by being in idle-in-transaction state, even without > backend_xmin and backend_xid, which prevents datfrozenxid from > advancing. While this might not be problematic in practice if it's > rare, I find it concerning that we have no way to check the age of > unconsumed notifications. > Ok, I think that I was too conservative when thinking about the transaction wraparound issue that it could happen. I agree that this seems a uncommon scenario. >> I think that to go with this solution we would need some way to drop too >> old notifications from the queue to advance the datfrozenxid, so I >> imagine that we would need some GUC to make this configurable and we can >> configure a default value of course but some use cases may not be the >> best configuration, this is something that users should expected to deal >> on minor version updates? >=20 > I think adding a new GUC would be overkill for this fix. As for > dropping old notifications from the queue, we probably don't need to > make it configurable - we could simply drop notifications whose commit > status is no longer available (instead of raising an error). > IIUC this is about not making the vacuum freeze considering the oldest xid on the queue but just remove notifications whose transaction status is no longer available right? Since currently when the error happens we already can't process the notifications it seems a reasonable way to go IMO. >> Going with the "self contained" idea sound more easier to backpatch >> actually, so this is the main reason that I abandoned this other >> approach. Could you please point what make the v8 version not visible >> for bachpatching? >=20 > Regarding the v8 patch, it introduces a fundamentally new way of > managing notification entries (adding entries with 'committed' state > and marking them 'aborted' in abort paths). This affects all use > cases, not just those involving very old unconsumed notifications, and > could introduce more serious bugs like PANIC or SEGV. For > backpatching, I prefer targeting just the problematic behavior while > leaving unrelated parts unchanged. Though =C3=81lvaro might have a > different perspective on this. > Thanks very much for this explanation and for what you've previously wrote on [1]. It's clear to me now that the v8 architecture is not a good way to go. [1] https://www.postgresql.org/message-id/CAD21AoCFZxXCBy%2B5DoarfG9LC9VdNw= WRDpDHE5sdTh5Ym0EcqQ%40mail.gmail.com --=20 Matheus Alcantara