pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Alvaro Herrera <alvherre@2ndquadrant.com>
Cc: Mithun Cy <mithun.cy@gmail.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Subject: Re: DROP OWNED CASCADE vs Temp tables
Date: Mon, 06 Apr 2020 15:08:49 -0400
Message-ID: <3019.1586200129@sss.pgh.pa.us> (raw)
In-Reply-To: <20200123171423.GA25918@alvherre.pgsql>
References: <20200123171423.GA25918@alvherre.pgsql>

Alvaro Herrera <alvherre@2ndquadrant.com> writes:
> On 2020-Jan-14, Alvaro Herrera wrote:
>> Hmm, it seems to be doing it differently.  Maybe it should be acquiring
>> locks on all objects in that nested loop and verified them for
>> existence, so that when it calls performMultipleDeletions the objects
>> are already locked, as you say.

> Yeah, this solves the reported bug.

I looked this over and think it should be fine.  There will be cases
where we get a deadlock error, but such risks existed anyway, since
we'd have acquired all the same locks later in the process.

> This is not a 100% solution: there's the cases when the user is removed
> from an ACL and from a policy, and those deletions are done directly
> instead of accumulating to the end for a mass deletion.

Let's worry about that when and if we get field complaints.

> I had to export AcquireDeletionLock (previously a static in
> dependency.c).  I wonder if I should export ReleaseDeletionLock too, for
> symmetry.

Hmmm ... there is an argument for doing ReleaseDeletionLock in the code
paths where you discover that the object's been deleted.  Holding a lock
on a no-longer-existent object OID should be harmless from a deadlock
standpoint; but it does represent useless consumption of a shared lock
table entry, and that's a resource this operation could already burn
with abandon.

Also, if we're exporting these, it's worth expending a bit more
effort on their header comments.  In particular AcquireDeletionLock
should describe its flags argument; perhaps along the lines of
"Accepts the same flags as performDeletion (though currently only
PERFORM_DELETION_CONCURRENTLY does anything)".

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <3019.1586200129@sss.pgh.pa.us>
Permalink:  ../3019.1586200129@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/3019.1586200129@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, alvherre@2ndquadrant.com, mithun.cy@gmail.com, pgsql-hackers@lists.postgresql.org
  Subject: Re: DROP OWNED CASCADE vs Temp tables
  In-Reply-To: <3019.1586200129@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox