Re: row-level deadlock problem

From: Kamil Kaczkowski <kamil(at)kamil(dot)eisp(dot)pl>
To: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Martijn van Oosterhout <kleptog(at)svana(dot)org>, pgsql-general(at)postgresql(dot)org
Subject: Re: row-level deadlock problem
Date: 2004-11-27 20:13:17
Message-ID: Pine.LNX.4.58.0411272046230.10312@virgo
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On Sat, 27 Nov 2004, Alvaro Herrera wrote:

> > You're mistaken; it takes a row lock on each row it updates. I'm not
> > sure why the two UPDATEs are visiting the same rows in different orders,
> > but if they do the failure is certainly possible.
>
> One of them could be using an indexscan while the other is not. If the
> heap is in reverse order compared to the scan, that would explain it.
>
> Is there a solution to this problem? The FK deadlock problem can be
> fixed with shared row locks, but this is a different one.
>
>
In my case deadlock happens between two identical statements executed
from different transactions and they have the same execution plan(index
scan on one attribute - 'color' in schema I presented).
Also, there's no other modifing statements in logs at the time so only
thing that can change scan order is the first UPDATE called of two
involved in deadlock(or the same statement exeduted from some third
transaction, but I don't think so).
Could someone with more knowledge on internals of btree indexes provide
info on how this can happen, what causes index scan order to change?
Thinking of it, possibility of such event should be very low, but I'm
getting 2000 deadlocks during busy day.
Regards.
--
Kamil Kaczkowski
kamil(at)kamil(dot)eisp(dot)pl

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Woodchuck Bill 2004-11-27 20:14:58 Re: Why the current setup of pgsql.* and comp.databases.postresql.general are BROKEN
Previous Message Alvaro Herrera 2004-11-27 19:29:48 Re: row-level deadlock problem