Re: Deadlock error in INSERT statements - Mailing list pgsql-hackers

From Csaba Nagy
Subject Re: Deadlock error in INSERT statements
Date
Msg-id 1254928125.3372.435.camel@pcd12478
Whole thread Raw
In response to Deadlock error in INSERT statements  (Gnanam <gnanam@zoniac.com>)
List pgsql-hackers
On Wed, 2009-10-07 at 16:34 +0200, Gnanam wrote:
> NOTE: I've seen "deadlock" errors in UPDATE statement but why it is throwing
> in INSERT statements.

It is because of the foreign key. Inserting a child row will lock the
corresponding parent row, and if you insert multiple rows with different
parents in the same transaction, and do that in different concurrent
transactions but in different order of the parent rows, you can get a
deadlock. If you keep in mind that the parent row is locked on the
insert of a child row, you will figure out what's happening...

BTW, I don't think the "hackers" list is the right one for this kind of
question, better use the "general" list...

Cheers,
Csaba.




pgsql-hackers by date:

Previous
From: Robert Haas
Date:
Subject: Re: Deadlock error in INSERT statements
Next
From: Joshua Tolley
Date:
Subject: Re: Feature Suggestion: PL/Js