On 6/20/17 19:10, Peter Eisentraut wrote: > On 6/19/17 22:54, Masahiko Sawada wrote: >>> It seems to me we could just take a stronger lock around >>> RemoveSubscriptionRel(), so that workers can't write in there concurrently. >> >> Since we reduced the lock level of updating pg_subscription_rel by >> commit 521fd4795e3e the same deadlock issue will appear if we just >> take a stronger lock level. > > I was thinking about a more refined approach, like in the attached > patch. It just changes the locking when in DropSubscription(), so that > that doesn't fail if workers are doing stuff concurrently. Everything > else stays the same.
The alternative is that we use the LockSharedObject() approach that was already alluded to, like in the attached patch. Both approaches would work equally fine AFAICT. -- Peter Eisentraut http://www.2ndQuadrant.com/ PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services
From 10afa9807014e14596cb05d70ba302c86bf30dd3 Mon Sep 17 00:00:00 2001 From: Peter Eisentraut <pete...@gmx.net> Date: Wed, 21 Jun 2017 22:40:22 -0400 Subject: [PATCH] WIP Add locking SetSubscriptionRelState() --- src/backend/catalog/pg_subscription.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/backend/catalog/pg_subscription.c b/src/backend/catalog/pg_subscription.c index c69c461b62..f794d4c526 100644 --- a/src/backend/catalog/pg_subscription.c +++ b/src/backend/catalog/pg_subscription.c @@ -28,6 +28,8 @@ #include "nodes/makefuncs.h" +#include "storage/lmgr.h" + #include "utils/array.h" #include "utils/builtins.h" #include "utils/fmgroids.h" @@ -246,6 +248,8 @@ SetSubscriptionRelState(Oid subid, Oid relid, char state, bool nulls[Natts_pg_subscription_rel]; Datum values[Natts_pg_subscription_rel]; + LockSharedObject(SubscriptionRelationId, subid, 0, AccessExclusiveLock); + rel = heap_open(SubscriptionRelRelationId, RowExclusiveLock); /* Try finding existing mapping. */ -- 2.13.1
-- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers