On Fri, 14 Dec 2001 pgsql-bugs@postgresql.org wrote:
> Eugene Fokin (elf@solvo.ru) reports a bug with a severity of 2
> The lower the number the more severe it is.
>
> Short Description
> Unexpected DeadLock on REFERENCES
>
> Long Description
> DeadLock happens when we're trying to concurrent update different
> tables which chained with one table through REFERENCE.
> See Example Code. Just perform the script and follow instructions
> on the header.
> This case have been checked on 7.1.3 version.
>
> Sample Code
> --
> -- At first you should execute this script.
> -- In two different sessions for one DB perform:
> -- (1) begin transaction;
> -- (2) begin transaction;
> -- (1) update ref1 set d='R11110';
> -- (2) update ref2 set d='R22220';
> -- (1) update ref3 set d='R33330';
> -- (2) update ref4 set d='R44440';
> -- !!! Didn't you get DeadLock ?
I get a detected deadlock. This is a known problem due to the
foreign key locks being stronger than necessary. I think
a shared row lock that blocks update/delete but not itself rather
than the current select for update lock would allow this case
to work.