Re: ALTER TABLE deadlock with concurrent INSERT - Mailing list pgsql-hackers

From Joe Conway
Subject Re: ALTER TABLE deadlock with concurrent INSERT
Date
Msg-id 4D7031C5.5040005@joeconway.com
Whole thread Raw
In response to Re: ALTER TABLE deadlock with concurrent INSERT  (Jim Nasby <jim@nasby.net>)
Responses Re: ALTER TABLE deadlock with concurrent INSERT
List pgsql-hackers
On 03/03/2011 03:49 PM, Jim Nasby wrote:
> On Mar 2, 2011, at 2:54 PM, Joe Conway wrote:
>> On 03/02/2011 12:41 PM, Tom Lane wrote:
>>> Looks like the process trying to do the ALTER has already got some
>>> lower-level lock on the table.  It evidently hasn't got
>>> AccessExclusiveLock, but nonetheless has something strong enough to
>>> block an INSERT, such as ShareLock.
>>
>> Hmmm, is it possible that the following might do that, whereas a simple
>> ALTER TABLE would not?
>
> Impossible to tell without seeing what's in the script... ie: if the script was
>
> BEGIN;
> -- Do something to that table that blocks inserts
> SELECT change_column_type(...);
> COMMIT;
>
> You'd get a deadlock.

The script was exactly the one posted, i.e.
BEGIN;
CREATE FUNCTION change_column_type(...);
SELECT change_column_type(...);
COMMIT;

That's all there is to it. And the function itself has no specific
reference to the table being altered. That's why I'm left scratching my
head ;-)

Joe


--
Joe Conway
credativ LLC: http://www.credativ.us
Linux, PostgreSQL, and general Open Source
Training, Service, Consulting, & 24x7 Support


pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: Quick Extensions Question
Next
From: Jim Nasby
Date:
Subject: Re: ALTER TABLE deadlock with concurrent INSERT