Re: Problem with ALTER TABLE - occasional "tuple concurrently updated"

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Alvaro Herrera <alvherre(at)commandprompt(dot)com>
Cc: Jon Nelson <jnelson+pgsql(at)jamponi(dot)net>, pgsql-bugs <pgsql-bugs(at)postgresql(dot)org>
Subject: Re: Problem with ALTER TABLE - occasional "tuple concurrently updated"
Date: 2011-03-03 16:20:44
Message-ID: AANLkTimnfrO=-C-jZA8NX7Bxp5gcSmgkduGequXPA0T1@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Thu, Nov 18, 2010 at 1:35 PM, Alvaro Herrera
<alvherre(at)commandprompt(dot)com> wrote:
> Excerpts from Alvaro Herrera's message of jue nov 18 15:31:16 -0300 2010:
>> Excerpts from Robert Haas's message of jue nov 18 15:11:37 -0300 2010:
>>
>> > In the current master branch, it appears that "ALTER TABLE c INHERIT
>> > p" takes a ShareUpdateExclusiveLock on the child, which seems
>> > sufficient, and an AccessShareLock on the parent, which seems like it
>> > might not be; though I'm having a hard time figuring out exactly when
>> > it wouldn't be, especially since in 8.4 I'm fairly sure any ALTER
>> > TABLE command takes an AccessExclusiveLock.
>>
>> What if two of these run at the same time, and the parent doesn't
>> have children when they start?  They would both try to set
>> relhassubclass, no?
>
> Yep, duplicated the issue that way.

I think ATExecAddInherit() and MergeAttributes() need to take
ShareUpdateExclusiveLock instead of AccessShareLock to prevent this.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Merlin Moncure 2011-03-03 16:22:16 Re: BUG #5911: pg_notify() function only works when channel name is lower case
Previous Message Ross Barrett 2011-03-03 16:14:22 Re: BUG #5899: Memory corruption when running psql