Re: deadlock detected, only selects (not select-for-update)

From: Gregory Stark <stark(at)enterprisedb(dot)com>
To: Gábor Farkas <gabor(at)nekomancer(dot)net>
Cc: <pgsql-general(at)postgresql(dot)org>
Subject: Re: deadlock detected, only selects (not select-for-update)
Date: 2007-10-24 09:13:35
Message-ID: 878x5sub7k.fsf@oxford.xeocode.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Gábor Farkas <gabor(at)nekomancer(dot)net> writes:

> BEGIN; SET TRANSACTION ISOLATION LEVEL SERIALIZABLE;
> now a lot of selects, but nothing complicated, all of the form of "SELECT x
> FROM y WHERE a=b", with some simple joins, and SELECT DISTINCT and ORDER BY.
> END;
>
> can any of these commands cause the mentioned deadlock?

No, a plain select without a "FOR SHARE" or "FOR UPDATE" can't cause a
deadlock.

One thing to be aware of is that In 7.4 foreign keys can cause spurious
deadlocks. Two updates against different records in a table will lock the
referenced keys. If they lock the referenced keys in different orders then
it's possible for them to deaadlock. This is addressed in more recent versions
of PostgreSQL.

--
Gregory Stark
EnterpriseDB http://www.enterprisedb.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message João Paulo Zavanela 2007-10-24 11:43:56 Install plJava
Previous Message cluster 2007-10-24 08:59:46 Re: Selecting K random rows - efficiently!