Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION - Mailing list pgsql-hackers

From Amit Kapila
Subject Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION
Date
Msg-id CAA4eK1L4wWiFnhDYhGMv-M4GTR6Xg13xoaSjhUm+YzFaP3nxUQ@mail.gmail.com
Whole thread Raw
In response to Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION  (Tomas Vondra <tomas.vondra@enterprisedb.com>)
Responses Re: undetected deadlock in ALTER SUBSCRIPTION ... REFRESH PUBLICATION
List pgsql-hackers
On Wed, Nov 22, 2023 at 4:51 PM Tomas Vondra
<tomas.vondra@enterprisedb.com> wrote:
>
> On 11/22/23 11:38, Amit Kapila wrote:
> >
> > Okay. IIUC, what's going on here is that the apply worker acquires
> > AccessShareLock on pg_subscription to update rel state for one of the
> > tables say tbl-1, and then for another table say tbl-2, it started
> > waiting for a state change via wait_for_relation_state_change(). I
> > think here the fix is to commit the transaction before we go for a
> > wait. I guess we need something along the lines of what is proposed in
> > [1] though we have solved the problem in that thread in some other
> > way..
> >
>
> Possibly. I haven't checked if the commit might have some unexpected
> consequences, but I can confirm I can no longer reproduce the deadlock
> with the patch applied.
>

Thanks for the verification. Offhand, I don't see any problem with
doing a commit at that place but will try to think some more about it.
I think we may want to call pgstat_report_stat(false) after commit to
avoid a long delay in stats.

I haven't verified but I think this will be a problem in back-branches as well.

--
With Regards,
Amit Kapila.



pgsql-hackers by date:

Previous
From: Andrei Lepikhov
Date:
Subject: Re: POC, WIP: OR-clause support for indexes
Next
From: Xiang Gao
Date:
Subject: RE: Question about the Implementation of vector32_is_highbit_set on ARM