Re: DROP OWNED CASCADE vs Temp tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>
Cc: Mithun Cy <mithun(dot)cy(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org>
Subject: Re: DROP OWNED CASCADE vs Temp tables
Date: 2020-01-14 00:27:05
Message-ID: 5771.1578961625@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Alvaro Herrera <alvherre(at)2ndquadrant(dot)com> writes:
> On 2020-Jan-07, Mithun Cy wrote:
>> I have a test where a user creates a temp table and then disconnect,
>> concurrently we try to do DROP OWNED BY CASCADE on the same user. Seems
>> this causes race condition between temptable deletion during disconnection
>> (@RemoveTempRelations(myTempNamespace)) and DROP OWNED BY CASCADE operation
>> which will try to remove same temp table when they find them as part of
>> pg_shdepend.

> Cute.

Is this really any worse than any other attempt to issue two DROPs against
the same object concurrently? Maybe we can just call it pilot error.

> This seems fiddly to handle better; maybe you'd have to have a new
> PERFORM_DELETION_* flag that says to ignore "missing" objects; so when
> you go from shdepDropOwned, you pass that flag all the way down to
> doDeletion(), so the objtype-specific function is called with
> "missing_ok", and ignore if the object has already gone away. That's
> tedious because none of the Remove* functions have the concept of
> missing_ok.

That seems fundamentally wrong. By the time we've queued an object for
deletion in dependency.c, we have a lock on it, and we've verified that
the object is still there (cf. systable_recheck_tuple calls).
If shdepDropOwned is doing it differently, I'd say shdepDropOwned is
doing it wrong.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2020-01-14 01:38:17 Re: BUG #16059: Tab-completion of filenames in COPY commands removes required quotes
Previous Message Michael Paquier 2020-01-14 00:19:38 Re: DROP OWNED CASCADE vs Temp tables

Browse pgsql-hackers by date

  From Date Subject
Next Message vignesh C 2020-01-14 00:32:56 Re: Add FOREIGN to ALTER TABLE in pg_dump
Previous Message Michael Paquier 2020-01-14 00:19:38 Re: DROP OWNED CASCADE vs Temp tables