Re: Concurrent CREATE TABLE/DROP SCHEMA leaves inconsistent leftovers - Mailing list pgsql-hackers

From Nikhil Sontakke
Subject Re: Concurrent CREATE TABLE/DROP SCHEMA leaves inconsistent leftovers
Date
Msg-id CANgU5Zc4D6VSihpWx7guvE_SPHzbZr9Vr2oFBd3Pr+sLrYpZEw@mail.gmail.com
Whole thread Raw
In response to Re: Concurrent CREATE TABLE/DROP SCHEMA leaves inconsistent leftovers  (Robert Haas <robertmhaas@gmail.com>)
Responses Re: Concurrent CREATE TABLE/DROP SCHEMA leaves inconsistent leftovers
List pgsql-hackers

 
> We definitely need some interlocking to handle this. For lack of better
> APIs, we could do a LockDatabaseObject() call in AccessShareLock mode on the
> namespace and release the same on completion of the creation of the object.
>
> Thoughts?

In general, we've been reluctant to add locking on non-table objects
for reasons of overhead.  You can, for example, drop a type or
function while a query is running that depends on it (which is not
true for tables).  But I think it is sensible to do it for DDL
commands, which shouldn't be frequent enough for the overhead to
matter much.  

Agreed. Especially if the race condition has non-trivial downsides as mentioned in the tablespace case.
 
When I rewrote the comment code for 9.1, I added locking
that works just this way, to prevent pg_description entries from being
orphaned; see the end of get_object_address().


Yeah thanks, that does the object locking. For pre-9.1 versions, we will need a similar solution. I encountered the issue on 8.3.x..

Regards,
Nikhils

pgsql-hackers by date:

Previous
From: Jaime Casanova
Date:
Subject: Re: Syntax for partitioning
Next
From: Tom Lane
Date:
Subject: Re: a modest improvement to get_object_address()