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 1uoqCd-00BFBm-2H for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Aug 2025 21:18:40 +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 1uoqCc-00BWsC-6x for pgsql-hackers@arkaria.postgresql.org; Wed, 20 Aug 2025 21:18:38 +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 1uoqCb-00BWqv-Ow for pgsql-hackers@lists.postgresql.org; Wed, 20 Aug 2025 21:18:38 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uoqCZ-000uQV-2w for pgsql-hackers@postgresql.org; Wed, 20 Aug 2025 21:18:37 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-323267bcee7so454660a91.1 for ; Wed, 20 Aug 2025 14:18:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1755724715; x=1756329515; darn=postgresql.org; h=content-transfer-encoding:in-reply-to:references:mime-version :subject:cc:to:from:message-id:date:from:to:cc:subject:date :message-id:reply-to; bh=bFB28+DmEoj1msvVBSfYY4qCDREuwpSwYuhU37K6Y7w=; b=OyE/0h5I+Y2tKvUxA9K6PsQL5GXrsvP/mufO9fPxBJYsKRoaJZIPgluD3GPx4mNU45 JzTJ3KPhEHr0Gr5PgMbtUeb9rP4Bq8/t4nXkWl6dl3ABEPf4XWBCHTVz11l5gHp6rgBv 9ZMXnuWUdhFp12rPAfT4VBkpTWFVJPwrPzm+XgDAgpmQ9Y6yRNpBrfOI2ImgSAgf24vz QiPrjmlHpq79j9dTMNgTtFbH0Xa80KgBhcncSKypZmWpmOg7BzA32/biqJbVaDxD08lH cZGb5EAXJfOOeA1SNvggkGBOhuiUecq0c4L9SBgRWogJTA9FTULzSfluQCe6MAdWhNF4 /s8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1755724715; x=1756329515; h=content-transfer-encoding:in-reply-to:references:mime-version :subject:cc:to:from:message-id:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bFB28+DmEoj1msvVBSfYY4qCDREuwpSwYuhU37K6Y7w=; b=ohm9Wk9HxGuv10+b0kpiZ8+s59MbOE2HuEBgBnASwoGdBOkK64Ag2/9ZmBAPHhXXgD Y/bBqZp66HK+th/8UMKezhWBdOWAkfkHvqopyi3HRpy2XIbgZum4fC8bLuxOZ5msE/XZ fCRj84uBL/BJmsv54wioGrLSDclQahYO12F12NedTxjWbvBgwPV3j10TqpJWEE4WQAgm KF8Lp49XdStypBfhlozIP/HFQfDBXXAp3uPIAuK9KK47YLANb4iUWM644qyvrASYJIxZ +LOJzZx7v5f2cz0JkWED4FF98N/Yp29fwyJInXxb7NN1rdt8bsGjhv6BbkfZYm2gpXcC H7NA== X-Forwarded-Encrypted: i=1; AJvYcCUNuQOCw/YqQalYTyN9Ll+F3bq9m5ESH4RZ+q8pUxiGQO20Yz7WRcWjeBjLfJGFSooJGwufQPFTFKs7TcjV@postgresql.org X-Gm-Message-State: AOJu0Yx7Y0N983tw4LjoXHwU+lrjEL7ULEP76b5VkgE2piCA8YCPd4Gr e7tpEWN+Tl2cMC3VVcLsBgGLtbCpUjD7wsCzSKlee3O/xXOaos5RK9Jv X-Gm-Gg: ASbGncvRvwtAuj/Vzn3XgxhfsT9NE6fdW2XaYaZR+qf6Ch6WdTjgrqfYLlj1154ob1F KxOediUeY+I4M1nb8ExAWq1+P6hPR4NCOf32ZA38uA9tD//jx7abk6ywwtefQjBIdyDY2SJA/BQ tEuNzBAAGWZDATKxJJhnAMxC2coqDFbwixTpbC7pAEOd8m2QAs1pt95eWoz8p66re8PjmUeARaH 8dT3Tc2ZODGk6Bn9lQBaB3YrZBSFKlwbxLiaTVVIPyfHZbvt2AqT/h8mYVqXTX1z8CU0odXEs1E 11gJrKFOGnuMho+1O9RHG/slshjE77KYRywNyP9SCWSR7+/eu1vQ1qWvUuHwpO8Jxuw3qNHSDBs mDfi57KLY1tTduH6q6381xIUDv3kXpSP/ZDmxiHGbbNwW X-Google-Smtp-Source: AGHT+IHtm/u0xodW/i/ygs+PV7RuwVsszrdU65rnUZiZzELpgikgEhDVM7xvSQi7dT97zNKV7UN9bA== X-Received: by 2002:a17:90b:314d:b0:31f:11d6:cea0 with SMTP id 98e67ed59e1d1-324ed1bfdd7mr304105a91.27.1755724715293; Wed, 20 Aug 2025 14:18:35 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:d4c:9a1a:a1e0:d913]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-324e2519d4esm3176346a91.5.2025.08.20.14.18.33 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 20 Aug 2025 14:18:34 -0700 (PDT) Content-Type: text/plain; charset=UTF-8 Date: Wed, 20 Aug 2025 18:18:32 -0300 Message-Id: From: "Matheus Alcantara" To: "Daniil Davydov" <3danissimo@gmail.com> Cc: =?utf-8?q?=C3=81lvaro_Herrera?= , "Alexandra Wang" , "PostgreSQL Hackers" Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue MIME-Version: 1.0 References: <202508061044.ptcyt7aqsaaa@alvherre.pgsql> In-Reply-To: Content-Transfer-Encoding: quoted-printable List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Tue Aug 19, 2025 at 2:37 PM -03, Daniil Davydov wrote: > Hi, > > On Tue, Aug 19, 2025 at 6:31=E2=80=AFPM Matheus Alcantara > wrote: >> >> On Tue Aug 19, 2025 at 12:57 AM -03, Daniil Davydov wrote: >> > You have started a very long transaction, which holds its xid and prev= ents >> > vacuum from freezing it. But what if the backend is stuck not inside a >> > transaction? Maybe we can just hardcode a huge delay (not inside the >> > transaction) or stop process execution via breakpoint in gdb. If we wi= ll use it >> > instead of a long query, I think that this error may be reproducible. >> > >> But how could this happen in real scenarios? I mean, how the backend >> could be stuck outside a transaction? >> > > For now, I cannot come up with a situation where it may be possible. > Perhaps, such a lagging may occur during network communication, > but I couldn't reproduce it. Maybe other people know how we can achieve > this? > Reading more the code I understand that once the a NOTIFY command is received by a backend (and the transaction is committed) it will emedialy signal all other listener backends and if the listener backend is in idle it will consume the notification and then send it back to the client as a PqMsg_NotificationResponse, so if there is a network delay to send the notification from the listener backend back to the client I don't think that it would be possible to get this error, because the message was already dispatched by the backend and it will eventually get to the client and once the notification is dispatched the backend doesn't need to track it anymore (the queue pointers of the backend are advanced after the dispatch). Assuming that every SQL command is wrapped into a transaction (if it's not already inside in) I think a busy listener backend will always prevent the vacuum from freezing clog files past from its current xid, so any notification that is sent while the backend is busy will not have their transaction status removed from clog files anyway. Is all these understandings and assumptions correct or am I missing something here? > I think that if such a situation may be possible, the suggestion to dele= te > messages will no longer be relevant. Therefore, first of all, I would li= ke to > clarify this issue. > From what I've understood until now it seems to me that this can happen only if we have a notification on the queue without any listener, so the notification may stay on the queue from a long time and a vacuum freeze can be executed during this time and then when we have a new listener (even for a different channel) it will fail to advance the pointers at listener setup(Exec_ListenPreCommit()) because it would not be able to get the transition status of this very old notification. (please note that I'm not trying to invalidate your concern, I'm also have this concern but unfortunately I'm unable to reproduce it and I'm just sharing my thoughts to see if this issue is really possible or not) -- Matheus Alcantara