Re: [PATCHES] Lock

From: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
To: peter_e(at)gmx(dot)net
Cc: PostgreSQL-development <pgsql-hackers(at)postgreSQL(dot)org>
Subject: Re: [PATCHES] Lock
Date: 1999-12-18 20:26:15
Message-ID: 199912182026.PAA05926@candle.pha.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> [Charset ISO-8859-1 unsupported, filtering to ASCII...]
> > I was looking at this
> >
> > * Allow LOCK TABLE tab1, tab2, tab3 so all tables locked in unison
> >
> > but I'm not sure if my solution is really what was wanted, because it
> > doesn't actually guarantee an all-or-nothing lock, it just locks each
> > table in order. Thus it's more like a syntax simplification and reduces
> > overhead.
> >
>
> It took a few minutes, but I remember the use for this. If you are
> going to hang waiting to lock tab3, you don't want to lock tab1 and tab2
> while you are waiting for tab3 lock. The user wanted all tables to lock
> in one operation without holding locks while waiting to complete all
> locking.
>
> Can you do the locks, and if one fails, not hang, but unlock the
> previous tables, go lock/hang on the failure, and go back and lock the
> others? Seems it would have to be some kind of lock/fail/unlock/wait
> loop.

[CC to hackers]

Let me add to this. One problem is that my description would sometimes
lock the tables in different orders, and that is a recipe for deadlock.

If you have to release earlier locks to wait on a later lock, once you
get the later lock, you must release it and then start from the
beginning, locking them in order again. If you don't, the system could
report a deadlock at random times, which would be very bad.

--
Bruce Momjian | http://www.op.net/~candle
maillist(at)candle(dot)pha(dot)pa(dot)us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Bruce Momjian 1999-12-18 20:32:35 Re: pgindent (Re: [HACKERS] LONG varsize - how to go on)t
Previous Message Bruce Momjian 1999-12-18 20:21:06 Re: initdb.sh fixed