Re: [HACKERS] Re: [PATCHES] Lock

From: Brook Milligan <brook(at)biology(dot)nmsu(dot)edu>
To: pgman(at)candle(dot)pha(dot)pa(dot)us
Cc: peter_e(at)gmx(dot)net, pgsql-hackers(at)postgreSQL(dot)org
Subject: Re: [HACKERS] Re: [PATCHES] Lock
Date: 1999-12-18 23:14:50
Message-ID: 199912182314.QAA03433@biology.nmsu.edu
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> > * Allow LOCK TABLE tab1, tab2, tab3 so all tables locked in unison

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.

I'll add something, too. :) I think this derived from a suggestion I
made long ago. My idea was that when multiple tables need locking, a
deadlock can occur in the process of doing them one at a time. My
suggested solution was based on an analogy with the way ethernet
packets work.

- go through the list locking tables along the way.

- if a lock cannot be obtained within some time, release some (all?) locks,
and try again after some random time.

- keep trying (and releasing as needed) until some other timeout
passes, and then punt.

My thought was that if colliding locks are occuring, some sequence of
relinquishing locks (not necessarily all of them with each trial),
waiting, and reasserting them should work around the collisions.
Introducing random components to this might reduce the overall waiting
time, but I suppose a careful analysis of this needs to be done.
Perhaps just releasing all of the locks, waiting a random time, and
trying again is enough.

Somehow there has to be a mechanism for atomically asserting locks on
more than one table.

Cheers,
Brook

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Mike Mascari 1999-12-18 23:50:57 Re: [HACKERS] SPI header dependencies
Previous Message Tom Lane 1999-12-18 22:14:07 Re: pgindent (Re: [HACKERS] LONG varsize - how to go on)