> Bruce Momjian wrote:
> >
> > The problem with this patch is that it doesn't always lock the tables in
> > the order supplied by the user, leading to possible deadlock. My guess
> > is that you need to try locking A, B, C and if B hangs, I think you need
> > to sleep on B, and when you get it, release the lock on B and try A, B,
> > C again. I know this is a pain and could fail multiple times, but I
> > think we have to do it this ay.
> >
>
> Deadlocks are not possible with this patch. The four conditions needed
> for deadlock are (according to Operating Systems: Internals and Design
> Principles, 4th Ed. by W. Stallings):
>
...
>
> The patch code never holds any of requested locks, while waiting for a
> locked relation to become free. If a lock on all tables in the lock list
> cannot be acquired at once, it backs off and releases all locks.
>
> Stallings writes about preventing condition 3: "This condition can be
> prevented in several ways. [. . .] [One way is to require that,] if a
> process holding certain resources is denied a further request, that
> process must release its original resources and, if necessary, request
> them again together with the additional resources."
>
> This is exactly what the patch does. Observe that if one lock is not
> available, the patch releases all locks so far acquired, and then
> acquires
> the locks again. Hence, condition 3 is prevented, and so deadlock is
> prevented.
Excellent point. I had not considered the fact that you don't hang
waiting for the other locks; you just release them all and try again.
Looks like a great patch, and it seems better than the OID patch in many
ways.
> p.s. Is this mailing list always this slow?
Not sure. I have gotten patches stuck in the patches queue recently.
Not sure on the cause. Marc may know.
--
Bruce Momjian | http://candle.pha.pa.us
pgman@candle.pha.pa.us | (610) 853-3000
+ If your life is a hard drive, | 830 Blythe Avenue
+ Christ can be your backup. | Drexel Hill, Pennsylvania 19026