Re: 024_add_drop_pub.pl might fail due to deadlock

Ajin Cherian <itsajin@gmail.com>

From: Ajin Cherian <itsajin@gmail.com>
To: vignesh C <vignesh21@gmail.com>
Cc: "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, Alexander Lakhin <exclusion@gmail.com>, pgsql-hackers <pgsql-hackers@postgresql.org>, Amit Kapila <amit.kapila16@gmail.com>
Date: 2025-07-31T10:52:26Z
Lists: pgsql-hackers

Attachments

On Thu, Jul 31, 2025 at 7:07 PM vignesh C <vignesh21@gmail.com> wrote:
>
> On Thu, 31 Jul 2025 at 08:23, Ajin Cherian <itsajin@gmail.com> wrote:
> >
> > On Wed, Jul 30, 2025 at 10:33 PM Hayato Kuroda (Fujitsu)
> > <kuroda.hayato@fujitsu.com> wrote:
> > >
> > > Dear Ajin,
> > >
> > > > Attaching the updated patches with the changes you requested. I've
> > > > also added the unchanged patches for PG_18 and HEAD (PG_18_HEAD-v6*),
> > > > so that everything is together in one mail.
> > >
> > > Thanks for update, but the patch for PG18/HEAD seemed not to have Assert().
> > > Can you modify like others do?
> > >
> >
> > Updated patch for PG18/HEAD.
>
> How about we change the below:
> +#ifdef USE_ASSERT_CHECKING
> +               LOCKTAG tag;
> +#endif
> +
> +               Assert(CheckRelationOidLockedByMe(SubscriptionRelRelationId,
> +
>            RowExclusiveLock, true));
> +
> +               rel = table_open(SubscriptionRelRelationId, NoLock);
> +#ifdef USE_ASSERT_CHECKING
> +               SET_LOCKTAG_OBJECT(tag, InvalidOid,
> SubscriptionRelationId, subid, 0);
> +               Assert(LockHeldByMe(&tag, AccessShareLock, true));
> +#endif
>
> to:
>  #ifdef USE_ASSERT_CHECKING
>         LOCKTAG tag;
>         Assert(CheckRelationOidLockedByMe(SubscriptionRelRelationId,
>                                           RowExclusiveLock, true));
>         SET_LOCKTAG_OBJECT(tag, InvalidOid, SubscriptionRelationId, subid, 0);
>         Assert(LockHeldByMe(&tag, AccessShareLock, true));
> #endif
>
>         rel = table_open(SubscriptionRelRelationId, NoLock);
>     }
>
> The rest looks good to me.

I've fixed the patches accordingly for all branches.

regards,
Ajin Cherian
Fujitsu Australia

Commits

  1. Fix a deadlock during ALTER SUBSCRIPTION ... DROP PUBLICATION.