Re: Debugging deadlocks

From: Alvaro Herrera <alvherre(at)dcc(dot)uchile(dot)cl>
To: Guy Rouillier <guyr(at)masergy(dot)com>
Cc: PostgreSQL General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Debugging deadlocks
Date: 2005-03-28 01:51:05
Message-ID: 20050328015105.GA28150@dcc.uchile.cl
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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[(at)]dcc(dot)uchile(dot)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)

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2005-03-28 01:56:34 Re: plpgsql no longer exists
Previous Message Mike Nolan 2005-03-28 01:46:41 Tablespaces and indexes