Re: DROP OWNED CASCADE vs Temp tables - Mailing list pgsql-hackers

From Tom Lane
Subject Re: DROP OWNED CASCADE vs Temp tables
Date
Msg-id 3019.1586200129@sss.pgh.pa.us
Whole thread Raw
In response to Re: DROP OWNED CASCADE vs Temp tables  (Alvaro Herrera <alvherre@2ndquadrant.com>)
Responses Re: DROP OWNED CASCADE vs Temp tables  (Alvaro Herrera <alvherre@2ndquadrant.com>)
List pgsql-hackers
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



pgsql-hackers by date:

Previous
From: David Steele
Date:
Subject: Re: Don't try fetching future segment of a TLI.
Next
From: Grigory Smolkin
Date:
Subject: Re: archive recovery fetching wrong segments