Re: 024_add_drop_pub.pl might fail due to deadlock

From: Ajin Cherian <itsajin(at)gmail(dot)com>
To: "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>
Cc: vignesh C <vignesh21(at)gmail(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>
Subject: Re: 024_add_drop_pub.pl might fail due to deadlock
Date: 2025-07-28 12:06:52
Message-ID: CAFPTHDbyXXbrtYgx=aweMe8YHTXMavJ2FeJmp3iBeEEDjWpbqw@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Fri, Jul 25, 2025 at 6:01 PM Hayato Kuroda (Fujitsu)
<kuroda(dot)hayato(at)fujitsu(dot)com> wrote:
>
> Dear Ajin,
>
> Thanks for patches! While checking, I recalled that the backpatch policy [1].
> We must not modify definitions of opened functions but this does. Can you define
> another function like UpdateSubscriptionRelStateEx or something on the back
> branches?
>
> Another comment:
> ```
> @@ -328,9 +328,13 @@ UpdateSubscriptionRelState(Oid subid, Oid relid, char state,
> Datum values[Natts_pg_subscription_rel];
> bool replaces[Natts_pg_subscription_rel];
>
> - LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
> -
> - rel = table_open(SubscriptionRelRelationId, RowExclusiveLock);
> + if (already_locked)
> + rel = table_open(SubscriptionRelRelationId, NoLock);
> ```
>
> Can we assert that RowExclusiveLock for pg_subscription_rel has already been
> acquired, by using CheckRelationOidLockedByMe() family?
>

Thanks for your review Kuroda-san, I have changed the logic to not use
already_locked and instead check if the locks are taken inside
UpdateSubscriptionRelState itself. I've tested this and this works
fine. If this logic is acceptable to the reviewers I can update the
other patches also in a similar way.

regards,
Ajin Cherian
Fujitsu Australia

Attachment Content-Type Size
PG_15-v5-0001-Fix-a-deadlock-during-ALTER-SUBSCRIPTION.-DROP-PU.patch application/octet-stream 4.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Daniel Gustafsson 2025-07-28 12:08:15 Re: Explicitly enable meson features in CI
Previous Message Andrew Dunstan 2025-07-28 12:04:34 Re: Non-text mode for pg_dumpall