Re: ALTER TABLE deadlock with concurrent INSERT

From: Joe Conway <mail(at)joeconway(dot)com>
To: Noah Misch <noah(at)leadboat(dot)com>
Cc: "Hackers (PostgreSQL)" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: ALTER TABLE deadlock with concurrent INSERT
Date: 2011-03-04 15:50:07
Message-ID: 4D710A2F.5090500@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 03/03/2011 11:36 PM, Noah Misch wrote:
> Does relation 16902 (attribute_summary) have a foreign key constraint over the
> sequence_number column, in either direction, with relation 16896? That would
> explain it:
>
> session 1: ALTER TABLE attribute_summary ... <sleeps after relation_openrv in transformAlterTableStmt>
> session 2: SELECT 1 FROM rel16896 LIMIT 0;
> session 2: SELECT 1 FROM attribute_summary LIMIT 0; <blocks>
> session 1: <wakes up; continues ALTER TABLE: deadlock upon locking rel16896>

Ah, OK -- then that would explain it as there are foreign keys on that
column. Thanks, hadn't thought about that aspect.

> Granted, the cure may be worse than the disease.

Right. I've already advised they shut down the application during the
alter table, which they can do (and in fact already do -- they were
restarting the application just prior to this step, which really makes
no sense anyway).

Thanks,

Joe

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

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Heikki Linnakangas 2011-03-04 15:52:29 Re: Re: PD_ALL_VISIBLE flag was incorrectly set happend during repeatable vacuum
Previous Message Tom Lane 2011-03-04 15:43:52 Re: Quick Extensions Question