Re: pg_restore dependencies - Mailing list pgsql-hackers

From Andrew Dunstan
Subject Re: pg_restore dependencies
Date
Msg-id 49DFCBBC.8070205@dunslane.net
Whole thread Raw
In response to Re: pg_restore dependencies  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: pg_restore dependencies  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-hackers

Tom Lane wrote:
> Andrew Dunstan <andrew@dunslane.net> writes:
>   
>> Tom Lane wrote:
>>     
>>> Doesn't that eliminate any chance of running two CREATE INDEXes
>>> concurrently on the same table?
>>>       
>
>   
>> No, since neither of them will have any locking dependencies, which are 
>> only for items that take an exclusive lock on the table(s), such as FK 
>> constraints.
>>     
>
> In that case a CREATE INDEX would also fail to be seen as conflicting
> with an ALTER ADD FOREIGN KEY, which I thought was the nub of Josh's
> complaint.
>
>             
>   

No it won't. 

What you're missing is that we need to compare the lockdeps of each item 
(i.e. both the candidate item and the running item) with all the deps 
(not just the lockdeps) of the other item. If neither item has any 
lockdeps there will be no conflict. This will allow concurrent index 
creation, since neither item will have any lockdeps. But it will prevent 
us selecting a create index that conflicts with a running FK creation or 
vice versa.

cheers

andrew


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: pg_restore dependencies
Next
From: Tom Lane
Date:
Subject: Re: pg_restore dependencies