Re: 024_add_drop_pub.pl might fail due to deadlock
Ajin Cherian <itsajin@gmail.com>
From: Ajin Cherian <itsajin@gmail.com>
To: Alexander Lakhin <exclusion@gmail.com>
Cc: pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2025-07-14T09:59:52Z
Lists: pgsql-hackers
Attachments
- 0002-Fix-a-deadlock-during-ALTER-SUBSCRIPTION-.-DROP-PUBL.patch (application/octet-stream) patch 0002
On Tue, Jul 8, 2025 at 8:41 PM Ajin Cherian <itsajin@gmail.com> wrote:
> Proposed fix:
> In process_syncing_tables_for_apply(), acquire an AccessExclusiveLock
> on SubscriptionRelRelationId before acquiring the lock on
> ReplicationOriginRelationId.
>
> Patch with fix attached.
> I'll continue investigating whether this issue also affects HEAD.
While debugging this further, I found that there is another lock taken
prior to this in AlterSubscription(),
/* Lock the subscription so nobody else can do anything with it. */
LockSharedObject(SubscriptionRelationId, subid, 0, AccessExclusiveLock);
Since this is the first lock taken while altering subscription, that
should also be taken first by the tablesync worker to avoid deadlock.
So, attaching a modified patch.
regards,
Ajin Cherian
Fujitsu Australia
Commits
-
Fix a deadlock during ALTER SUBSCRIPTION ... DROP PUBLICATION.
- 2ab2d6f97058 19 (unreleased) landed
- d9f01a287ab1 18.0 landed
- 434d2d147b58 15.14 landed
- 41fb3f51cb74 14.19 landed
- 8c298324a4f3 17.6 landed
- adfd8021911a 16.10 landed