Re: Debugging deadlocks - Mailing list pgsql-general

From Alvaro Herrera
Subject Re: Debugging deadlocks
Date
Msg-id 20050328015105.GA28150@dcc.uchile.cl
Whole thread Raw
In response to Re: Debugging deadlocks  ("Guy Rouillier" <guyr@masergy.com>)
List pgsql-general
On Sun, Mar 27, 2005 at 06:02:25PM -0600, Guy Rouillier wrote:

> With the current implementation, it appears I need to either (1) always
> commit after every inserted row, or (2) single thread my entire insert
> logic.  Neither of these two alternatives is very desirable.

I think a usual workaround is to declare the contraints INITIALLY
DEFERRED.  This will delay the check until commit time, so the time
window to deadlock is smaller.  There still is a possibility though, so
you need to take it into account.  It occurs to me that if you control
all insertion threads, you could try to serialize access to COMMIT in
order to make the chance of deadlock even smaller.

--
Alvaro Herrera (<alvherre[@]dcc.uchile.cl>)
"Industry suffers from the managerial dogma that for the sake of stability
and continuity, the company should be independent of the competence of
individual employees."                                      (E. Dijkstra)

pgsql-general by date:

Previous
From: Mike Nolan
Date:
Subject: Tablespaces and indexes
Next
From: Tom Lane
Date:
Subject: Re: plpgsql no longer exists