Re: Re-read subscription state after lock in AlterSubscription
Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
From: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
To: Dilip Kumar <dilipbalaut@gmail.com>
Cc: Amit Kapila <amit.kapila16@gmail.com>, "Zhijie Hou (Fujitsu)" <houzj.fnst@fujitsu.com>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2026-07-04T08:19:46Z
Lists: pgsql-hackers
Hi, On Sat, Jul 04, 2026 at 01:30:08PM +0530, Dilip Kumar wrote: > On Fri, Jul 3, 2026 at 9:09 PM Bertrand Drouvot > <bertranddrouvot.pg@gmail.com> wrote: > > > > But while doing this and looking closely, I'm not sure AlterPublication() does > > it right. Indeed, in theory, the OID could have been re-used too (between the > > time we did the name resolution and the time we lock the publication). I think > > what is needed is something similar to RangeVarGetRelidExtended(), means do the > > name resolution, acl check (ownership) and lock acquisition, all in unison. > > > > That's what 0003 is trying to achieve for the subscription and 0004 for the > > publication. > > > > What do you think? > > > 0003: > > It looks like the implementation of DROP SUBSCRIPTION IF EXISTS has a > concurrent drop race condition in DropSubscription(). Currently, if > stmt->missing_ok is true, the initial lookup safely handles a missing > subscription. However, once a subscription is found and the code > enters the drop loop, a second internal lookup/refetch happens. If a > concurrent transaction drops the subscription after our initial check > but before this internal refetch, the code throws an error. > Essentially, the loop completely ignores the missing_ok flag during > the refetch phase. Good catch, will fix, thanks! Regards, -- Bertrand Drouvot PostgreSQL Contributors Team RDS Open Source Databases Amazon Web Services: https://aws.amazon.com