Received: from localhost (maia-3.hub.org [200.46.204.184]) by postgresql.org (Postfix) with ESMTP id 684A19FB6DF for ; Mon, 12 Feb 2007 15:27:27 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.184]) (amavisd-new, port 10024) with ESMTP id 73878-01 for ; Mon, 12 Feb 2007 15:27:16 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.4 Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by postgresql.org (Postfix) with ESMTP id 9536D9FB659 for ; Mon, 12 Feb 2007 15:27:16 -0400 (AST) Received: by ug-out-1314.google.com with SMTP id k3so1352911ugf for ; Mon, 12 Feb 2007 11:27:15 -0800 (PST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=CJW0WVPu/muCxY1oVoOWJ1jajT0LSPy66yWdqYDXYt1O4ByPiIWEVPGJs1t/JBdXRzzoXa2P13AUvp2T5FXlyLrGP/kHGqsfVtUHU7vFncom7zjYYzNqiqhy13MPJXKtkV3v1qJ3BwHN7u0TloC2a9++0OKs5FfUHTclNQMvXes= Received: by 10.66.225.1 with SMTP id x1mr12760832ugg.1171308435355; Mon, 12 Feb 2007 11:27:15 -0800 (PST) Received: by 10.66.217.13 with HTTP; Mon, 12 Feb 2007 11:27:15 -0800 (PST) Message-ID: <55c095e90702121127rf7daaebodf2efe1a5e1d2dcd@mail.gmail.com> Date: Mon, 12 Feb 2007 16:27:15 -0300 From: "Ezequias Rodrigues da Rocha" To: pgsql-sql@postgresql.org Subject: Re: [ADMIN] Deadlock on transaction In-Reply-To: <20070212185919.GG677@spoetnik.xs4all.nl> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_80809_3748839.1171308435308" References: <55c095e90702120943v2909044eo91445b0eda3958c7@mail.gmail.com> <1171302488.3565.15.camel@state.g2switchworks.com> <55c095e90702121008u6d3d27c0m16e52d63f97c3e7d@mail.gmail.com> <20070212185919.GG677@spoetnik.xs4all.nl> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.274 tagged_above=0 required=5 tests=AWL, BAYES_50, HTML_MESSAGE, SPF_PASS X-Spam-Level: X-Archive-Number: 200702/151 X-Sequence-Number: 27485 ------=_Part_80809_3748839.1171308435308 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline Ok you teach me. Thank you and sorry. :( I just want to know why is it occuring. I am pretty sad. Ezequias 2007/2/12, Reinoud van Leeuwen : > > On Mon, Feb 12, 2007 at 03:08:27PM -0300, Ezequias Rodrigues da Rocha > wrote: > > I mean really deadlock. Other transactions can't access the database > until > > the main transaction is complete. > > What you describe sounds like a blocking lock: one transaction uses a > resource and another has to wait until it is not locked anymore > > A deadlock is a special case: two transactions both need resources A and > B. transaction 1 locks A, and the next moment transaction 2 locks B. Now > transaction 1 waits for 2 to release B, but at the same time 2 waits for 1 > to release A. This is called a deadlock, or circulair lock. > Postgresql automatically detects such a situation and rolls one of them > back. The client recieves a 'restartable database error' and that is > exactly true: ususally another try will work. > > One method of fixing deadlocks is to make sure all your code accesses the > database in the same order. Alphabetically is easiest to remember... > ------=_Part_80809_3748839.1171308435308 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Ok you teach me. Thank you and sorry. :(

I just want to know why is it occuring. I am pretty sad.

Ezequias

2007/2/12, Reinoud van Leeuwen < reinoud.v@n.leeuwen.net>:
On Mon, Feb 12, 2007 at 03:08:27PM -0300, Ezequias Rodrigues da Rocha wrote:
> I mean really deadlock. Other transactions can't access the database until
> the main transaction is complete.

What you describe sounds like a blocking lock: one transaction uses a
resource and another has to wait until it is not locked anymore

A deadlock is a special case: two transactions both need resources A and
B. transaction 1 locks A, and the next moment transaction 2 locks B. Now
transaction 1 waits for 2 to release B, but at the same time 2 waits for 1
to release A. This is called a deadlock, or circulair lock.
Postgresql automatically detects such a situation and rolls one of them
back. The client recieves a 'restartable database error' and that is
exactly true: ususally another try will work.

One method of fixing deadlocks is to make sure all your code accesses the
database in the same order. Alphabetically is easiest to remember...
------=_Part_80809_3748839.1171308435308--