Re: Debugging deadlocks - Mailing list pgsql-general

From Martijn van Oosterhout
Subject Re: Debugging deadlocks
Date
Msg-id 20050328134715.GA29581@svana.org
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.  And it is
> only a partial fix (which will work in my case since I'm the only one
> updating this database.)  In the general case though, where other
> programmers may be writing code that I may not even know about to update
> parts of this database, avoiding this type of deadlock becomes very
> difficult.  It pretty much requires that everyone know what everyone
> else is doing.

The other possibility is to sort the rows on the foreign key as they
are inserted. Then the locks will always be taken in the same order and
hence can never deadlock.

Hope this helps,
--
Martijn van Oosterhout   <kleptog@svana.org>   http://svana.org/kleptog/
> Patent. n. Genius is 5% inspiration and 95% perspiration. A patent is a
> tool for doing 5% of the work and then sitting around waiting for someone
> else to do the other 95% so you can sue them.

Attachment

pgsql-general by date:

Previous
From: Gustavo Franklin Nóbrega - Planae
Date:
Subject: Re: pg_xlog disk full error, i need help
Next
From: Christopher Browne
Date:
Subject: Re: Linux Filesystem for PG