Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database - Mailing list pgsql-bugs

From Amit Kapila
Subject Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database
Date
Msg-id CAA4eK1+q3hz-67UzxsvaDDvhapquwe+vm+rfY-f3mPptvQto=g@mail.gmail.com
Whole thread Raw
In response to Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database  (Dilip Kumar <dilipbalaut@gmail.com>)
Responses Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database
List pgsql-bugs
On Wed, Aug 13, 2025 at 3:00 PM Dilip Kumar <dilipbalaut@gmail.com> wrote:
>
> I have prepared back branch patches.
>

@@ -1802,11 +1802,7 @@ DropSubscription(DropSubscriptionStmt *stmt,
bool isTopLevel)
...
- /*
- * Lock pg_subscription with AccessExclusiveLock to ensure that the
- * launcher doesn't restart new worker during dropping the subscription
- */
- rel = table_open(SubscriptionRelationId, AccessExclusiveLock);
+ rel = table_open(SubscriptionRelationId, AccessShareLock);

We need to acquire RowExclusiveLock here as we are deleting the
subscription row during this operation. See docs [1] and
AlterSubscription() code for reference. Attached is a top-up patch to
fix this for HEAD. Additionally, I have edited a few comments. If you
agree with these changes then please prepare backbranch patches
accordingly.

[1] - https://www.postgresql.org/docs/devel/explicit-locking.html
--
With Regards,
Amit Kapila.

Attachment

pgsql-bugs by date:

Previous
From: Laurenz Albe
Date:
Subject: Re: BUG #19019: Feature Request: allow the use of column reference in DEFAULT expression
Next
From: Dilip Kumar
Date:
Subject: Re: BUG #18988: DROP SUBSCRIPTION locks not-yet-accessed database