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 1uzcEI-005W26-Pp for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Sep 2025 14:36:54 +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 1uzcEG-007kGg-Lz for pgsql-hackers@arkaria.postgresql.org; Fri, 19 Sep 2025 14:36:52 +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 1uzcEG-007kGX-8J for pgsql-hackers@lists.postgresql.org; Fri, 19 Sep 2025 14:36:52 +0000 Received: from mail-pg1-x531.google.com ([2607:f8b0:4864:20::531]) by makus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256 (Exim 4.96) (envelope-from ) id 1uzcED-001HdR-1J for pgsql-hackers@postgresql.org; Fri, 19 Sep 2025 14:36:51 +0000 Received: by mail-pg1-x531.google.com with SMTP id 41be03b00d2f7-b54a588ad96so1629392a12.1 for ; Fri, 19 Sep 2025 07:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1758292609; x=1758897409; 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=3+UVKJtmy5tVqNLhGoa89lHPH8QkXHviXDNI2iTN5eM=; b=kCaHD0v2DhwbIqp2R70sQ8BmWIjlAbx+btPC6SWvrO+Hh1e6mcTsT/HggPaWf8n+Wm HfnmKeKrElvhL2jCFBhuXBiSMvgVdViGgRR9f2+7o7dbN/2ozImmtct2qQOJK2qX1SU3 /RjIcbKo3Iae4sEv3FTVNG78o2Ikjpqo3C7eN5p27LPZ9k57guyOSkedFtg8zGWsk6wr SrezgUQa3r4rH9HO9OEHSub8hx/9fUFgMJEI1/wObdSO6LJENIq2M3C1KE/hDWKd4ZBj mNt+z65uAOsaXsiPAK6KHiVJo6wqSb0N/z7wRClCpkjj6s4Ay2JQegf6YUqoZ64a9+0C dAIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1758292609; x=1758897409; 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=3+UVKJtmy5tVqNLhGoa89lHPH8QkXHviXDNI2iTN5eM=; b=M+jIGO4egO2CjF/ueb0We2xA4YTnqem/bjuxeUv3NhK+c/OP3TLbZJKyPE9nlMf0jW RDhm/blcibHW5/pqz9jA2dETAqYkoCvi5YbqKOLzL4LZ5BXPYrEUCHBdrdqaeD+98zGq 7GusOlOYqVlCoYDQdowuChVsd2wfxH0xWYVy9HyjGsnkaY/oiVdy2HaW7yUQvztHWOTg 8fJ5BoZ4a6pmbS/JiU9GRVfNRi8jDnRVVwIQEYCExIKJ2PoL2CB8tpKSe2ODyXtDroi8 GSKBQSGS8h2AfnPx0Dnqu3p+9cdbwUdFfLCXoEieisWyp8IhhixxnBo3rF4f3t5FIENb n27w== X-Forwarded-Encrypted: i=1; AJvYcCV99GyDGfEpofnsv47ilaDaBdejMIF5cDMEZpievLZPfAE6lNmMk7EDmEUoz7NUBzrcA6klySrmszsTYVvm@postgresql.org X-Gm-Message-State: AOJu0Yxm1TD8xF3bjwnpuqtE1bCUTKqsdOyqX0QDKetDPmSAp/5IT19m 8i8jAB1icOQ32Pfs+LswJ1Un8gnJySD6JDO1/GcDo1cBd5OY2Ow6edRm X-Gm-Gg: ASbGnctmdMVqVYxO9ANEGZlFYZwj/EyGa7mACb7NkYQ3Hg9Re1OGUbTfb3RTAjONkeR s8XoIZh133fuCgT00TGCeDBIlBl5JDJbMyLzDcjpaz7klNX6gJhn2fOdKzzuebiffRg0dbrnfpH 1J8jv8yrYJEJUmBoipsOlQ1NxBvg9xSvNPi+esW67gQiIO9kXejJVHm6ZfONOdC6SLEjuZfj7uN 45ObQxsVzBNoVbcURsHtgJTk7Ysh/FYgiAs6okEY391Eud6kvexbEb4Oq+/Uu8I8j30XvMsWpV+ 0fK8Kk4mgFgDdTeutxSZzIBUBpe2ex5f/htVwx7dQHXAkRKjuxhMadGo7D2htyWhDiXvC+z5ZjR 3a/LpIjPWOglRurUR2SzfeuAY7bxXwAGVzsrg7X9082/SQg== X-Google-Smtp-Source: AGHT+IEDm2VbiQvZKFFpAr861W89cUreYg+puvCOZlpUB81Y5ghnsMUqVuu4rZeVdxFVGOvjMAeqTw== X-Received: by 2002:a17:902:6902:b0:269:7840:de24 with SMTP id d9443c01a7336-2697cfd0e76mr70025575ad.21.1758292608706; Fri, 19 Sep 2025 07:36:48 -0700 (PDT) Received: from localhost ([2804:14d:328a:a59c:6011:7ca3:1871:de9e]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-269800530d8sm57465935ad.24.2025.09.19.07.36.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Sep 2025 07:36:48 -0700 (PDT) Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Fri, 19 Sep 2025 11:36:43 -0300 Message-Id: From: "Matheus Alcantara" To: "Arseniy Mukhin" Cc: "Masahiko Sawada" , "Rishu Bagga" , "Yura Sokolov" , "Daniil Davydov" <3danissimo@gmail.com>, =?utf-8?q?=C3=81lvaro_Herrera?= , "Alexandra Wang" , "PostgreSQL Hackers" , "Tom Lane" , "Joel Jacobson" Subject: Re: LISTEN/NOTIFY bug: VACUUM sets frozenxid past a xid in async queue X-Mailer: aerc 0.20.1 References: <202508061044.ptcyt7aqsaaa@alvherre.pgsql> In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Fri Sep 19, 2025 at 9:34 AM -03, Arseniy Mukhin wrote: > Hi, > Thanks for taking a look at this! > I like this approach. We got rid of dependency on clog and don't limit > vacuum. Several points about the fix: > > Is it correct to remember and reuse slru slots here? IIUC we can't do > it if we don't hold SLRU bank lock, because by the time we get in > AtAbort_Notify() the queue page could be already evicted. Probably we > need to use SimpleLruReadPage after we acquire the lock in > AtAbort_Notify()? > Yeah, I think it make sense. Maybe we could just store the page number and offset and call SimpleLruReadPage() inside AtAbort_Notify() to get the slotno? > I think adding a boolean 'committed' is a good approach, but what do > you think about setting the queue head back to the position where > aborted transaction notifications start? We can do such a reset in > AtAbort_Notify(). So instead of marking notifications as > 'commited=3Dfalse' we completely erase them from the queue by moving the > queue head back. From listeners perspective if there is a notification > of completed transaction in the queue - it's always a committed > transaction, so again get rid of TransactionIdDidCommit() call. It > seems like a simpler approach because we don't need to remember all > notifications positions in the queue and don't need the additional > field 'committed'. All we need is to remember the head position before > we write anything to the queue, and reset it back if there is an > abort. IIUC Listeners will never send such erased notifications: > - while the aborted transaction is looking like 'in progress', > listeners can't send its notifications. > - by the time the aborted transaction is completed, the head is > already set back so erased notifications are located after the queue > head and listeners can't read it. > I think that with this approach we may have a scenario where when we enter the AtAbort_Notify() the queue head may not be the notification from the transaction being aborted but it can be a notification from another committed transaction, so resetting the queue head back to the position before the aborted transaction would make us lose the notification from the committed transaction. Is that make sense? What do you think? > I think it's a good test to have. FWIW there is a way to reproduce the > test condition without the injection point. We can use the fact that > serializable conflicts are checked after tx adds notifications to the > queue. Please find the attached patch with the example tap test. Not > sure if using injections points is more preferable? > Great, I think that if we can have a way to reproduce this without an injection point would be better. I dind't look the test yet but I'll try to incorporate this on the next patch version. Thanks! -- Matheus Alcantara