Re: FK deadlock problem addressed

From: Dennis Gearon <gearond(at)cvc(dot)net>
To: Jan Wieck <JanWieck(at)Yahoo(dot)com>
Cc: PostgreSQL development <pgsql-hackers(at)postgresql(dot)org>, PostgreSQL general <pgsql-general(at)postgresql(dot)org>
Subject: Re: FK deadlock problem addressed
Date: 2003-04-07 21:17:23
Message-ID: 3E91EAE3.5060608@cvc.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-hackers

If Liberty RMS help pay for your work on this, send them my thanks, please!

Jan Wieck wrote:
> On behalf of Liberty RMS I looked at the deadlock problems caused by our
> implementation of foreign keys. Thanks to peer review and help from
> Stephan Szabo and Tom Lane (Stephan actually had "the" idea) it turned
> out that the comment I wrote in December 1999 was wrong.
>
> I just committed a small change to ri_triggers.c that fires the NO
> ACTION trigger every time after the SET DEFAULT trigger updated the FK
> table. That will catch the case where we delete or update the primary
> key consisting of the default values of a foreign key, which was the
> reason why we did the check on UPDATE even if the foreign key values
> don't change.
>
> Updating a row that has foreign keys without touching the foreign key
> values will not try to lock the referenced rows any more. This should
> avoid most of the deadlock problems reported (we still have to do the
> FOR UPDATE lock if the FK values change until we have a better lock or
> lookup mechanism). As a side effect, it increases the performance of
> such updates significantly.
>
> I also have patches for this available for 7.3.2 and 7.2.4. I will post
> a separate message for discussion if we want to backpatch.
>
>
> Jan
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-04-07 21:31:29 Re: Why no performance boost although I added an index?
Previous Message Dan Langille 2003-04-07 21:14:54 Re: possible time change issue - known problem?

Browse pgsql-hackers by date

  From Date Subject
Next Message Greg Stark 2003-04-07 22:05:56 Re: No merge sort?
Previous Message Dann Corbit 2003-04-07 21:02:30 Re: No merge sort?