From: | vignesh C <vignesh21(at)gmail(dot)com> |
---|---|
To: | Ajin Cherian <itsajin(at)gmail(dot)com> |
Cc: | Amit Kapila <amit(dot)kapila16(at)gmail(dot)com>, "Hayato Kuroda (Fujitsu)" <kuroda(dot)hayato(at)fujitsu(dot)com>, Alexander Lakhin <exclusion(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
Subject: | Re: 024_add_drop_pub.pl might fail due to deadlock |
Date: | 2025-07-29 10:56:21 |
Message-ID: | CALDaNm2XE2PA29httQR2sC5fg7r_7-G7sgoYd_WA8qyGo=KUPw@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
On Tue, 29 Jul 2025 at 14:46, Ajin Cherian <itsajin(at)gmail(dot)com> wrote:
>
> On Tue, Jul 29, 2025 at 1:13 PM Amit Kapila <amit(dot)kapila16(at)gmail(dot)com> wrote:
> >
> > Yes, that makes sense to me. For HEAD and PG18, we can still add a new
> > argument to the API. For other bank branches, it is better to use a
> > new Ex function as suggested by Kuroda-San.
> >
>
> Here are the updated patches.
I noticed the order of LockSharedObject and table lock is different
here compared to disable subscription:
@@ -492,7 +494,17 @@ process_syncing_tables_for_apply(XLogRecPtr current_lsn)
* worker to remove the origin
tracking as if there is any
* error while dropping we won't
restart it to drop the
* origin. So passing missing_ok = true.
+ *
+ * Lock the subscription and origin in
the same order as we
+ * are doing during DDL commands to
avoid deadlocks. See
+ * AlterSubscription_refresh.
*/
+
LockSharedObject(SubscriptionRelationId, MyLogicalRepWorker->subid,
+ 0,
AccessShareLock);
+
+ if (!rel)
+ rel =
table_open(SubscriptionRelRelationId, RowExclusiveLock);
DisableSubscription(Oid subid)
{
....
rel = table_open(SubscriptionRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(SUBSCRIPTIONOID, ObjectIdGetDatum(subid));
if (!HeapTupleIsValid(tup))
elog(ERROR, "cache lookup failed for subscription %u", subid);
LockSharedObject(SubscriptionRelationId, subid, 0, AccessShareLock);
....
Do we need to enforce consistent lock ordering here, or is it safe to
ignore because we're only using AccessShareLock?
Regards,
Vignesh
From | Date | Subject | |
---|---|---|---|
Next Message | Amit Kapila | 2025-07-29 11:09:29 | Re: 024_add_drop_pub.pl might fail due to deadlock |
Previous Message | Fujii Masao | 2025-07-29 10:45:08 | Re: Logical replication launcher did not automatically restart when got SIGKILL |