Re: locks in CREATE TRIGGER, ADD FK

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Christopher Kings-Lynne <chriskl(at)familyhealth(dot)com(dot)au>, Russell Smith <mr-russ(at)pws(dot)com(dot)au>, Neil Conway <neilc(at)samurai(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: locks in CREATE TRIGGER, ADD FK
Date: 2005-03-28 05:04:01
Message-ID: 200503280504.j2S541B12913@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Alvaro Herrera wrote:
> On Wed, Mar 23, 2005 at 10:42:01AM +0800, Christopher Kings-Lynne wrote:
> > >>If you want to be my friend forever, then fix CLUSTER so that it uses
> > >>sharerowexclusive as well :D
> > >
> > >I don't think it's as easy as that, because you have to move tuples
> > >around in the cluster operation. Same sort of issue as vacuum full I
> > >would suggest.
> >
> > Cluster doesn't move rows...
> >
> > I didn't say it was easy. It would involve changing how cluster works.
> > It would keep the old table around while building the new, then grab
> > an exclusive lock to swap the two.
>
> Huh, cluster already does that.
>
> I don't remember what the rationale was for locking the table, leaving
> even simple SELECTs out. (In fact, IIRC the decision wasn't made by me,
> and it wasn't discussed at all.)
>

The issue is that we would have to escalate the shared lock to exclusive
to swap out the files, and lock escallation could lead to
deadlock/starvation.

--
Bruce Momjian | http://candle.pha.pa.us
pgman(at)candle(dot)pha(dot)pa(dot)us | (610) 359-1001
+ If your life is a hard drive, | 13 Roberts Road
+ Christ can be your backup. | Newtown Square, Pennsylvania 19073

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Oleg Bartunov 2005-03-28 06:09:19 Re: postgreSQL and history of relational databases
Previous Message Jaime Casanova 2005-03-28 04:12:27 Re: rewriter in updateable views