Re: Somebody has not thought through subscription locking considerations - Mailing list pgsql-hackers

From Tom Lane
Subject Re: Somebody has not thought through subscription locking considerations
Date
Msg-id 12121.1491002446@sss.pgh.pa.us
Whole thread Raw
In response to Re: Somebody has not thought through subscription lockingconsiderations  (Petr Jelinek <petr.jelinek@2ndquadrant.com>)
List pgsql-hackers
Petr Jelinek <petr.jelinek@2ndquadrant.com> writes:
> But the pg_subscription_rel is also not accessed on heap_open, the
> problematic code is called from heap_drop_with_catalog. And VACUUM FULL
> pg_class calls heap_drop_with_catalog() when doing the heap swap (and it
> goes through performDeletion so through dependency info which is what I
> mean by everything else does this).

Hmmm.  What the heap_drop_with_catalog call is being applied to is a
short-lived table that is not pg_class.  It happens to own the disk
storage that used to belong to pg_class, but it is not pg_class;
in particular it doesn't have the same OID, and it is not what would
be looked in if someone happened to need to fetch a pg_class row
at that point.  So there's no circularity involved.

However ... by that same token, it ought to be okay to consult
pg_subscription_rel during that drop step.  Indeed, if we put
an IsCatalogRelation check in there, it wouldn't fire, because
the target table has OID 16409 according to your stack trace.
So that line of thought is indeed not very helpful.

On further reflection it seems like you were right, the problem is
taking a self-exclusive lock on pg_subscription_rel during low-level
catalog operations.  We're going to have to find a way to reduce that
lock strength, or we're going to have a lot of deadlock problems.
        regards, tom lane



pgsql-hackers by date:

Previous
From: Michael Paquier
Date:
Subject: Re: postgres_fdw IMPORT SCHEMA and partitioned tables
Next
From: Peter Geoghegan
Date:
Subject: Re: WIP: Covering + unique indexes.