Received: from localhost (maia-1.hub.org [200.46.204.191]) by postgresql.org (Postfix) with ESMTP id B51B19FB683; Mon, 12 Feb 2007 15:03:26 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.191]) (amavisd-new, port 10024) with ESMTP id 05704-02; Mon, 12 Feb 2007 15:03:17 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 X-Greylist: from auto-whitelisted by SQLgrey-1.7.4 Received: from mail.metronet.co.uk (mail.metronet.co.uk [213.162.97.75]) by postgresql.org (Postfix) with ESMTP id 6EC129FB631; Mon, 12 Feb 2007 15:03:08 -0400 (AST) Received: from server3.office.archonet.com (84-51-143-99.archon037.adsl.metronet.co.uk [84.51.143.99]) by smtp.metronet.co.uk (MetroNet Mail) with ESMTP id 0E4B21433D3; Mon, 12 Feb 2007 18:57:41 +0000 (GMT) Received: from [192.168.1.36] (dell36.office.archonet.com [192.168.1.36]) by server3.office.archonet.com (Postfix) with ESMTP id E759B274160; Mon, 12 Feb 2007 18:57:40 +0000 (GMT) Message-ID: <45D0B8A4.7000602@archonet.com> Date: Mon, 12 Feb 2007 18:57:40 +0000 From: Richard Huxton User-Agent: IceDove 1.5.0.9 (X11/20061220) MIME-Version: 1.0 To: Ezequias Rodrigues da Rocha Cc: Scott Marlowe , pgsql-sql@postgresql.org, pgsql-admin@postgresql.org Subject: Re: [SQL] Deadlock on transaction References: <55c095e90702120943v2909044eo91445b0eda3958c7@mail.gmail.com> <1171302488.3565.15.camel@state.g2switchworks.com> <55c095e90702121008u6d3d27c0m16e52d63f97c3e7d@mail.gmail.com> <45D0B565.9060402@archonet.com> <55c095e90702121047x1c66b098xbcf0d308195ff584@mail.gmail.com> In-Reply-To: <55c095e90702121047x1c66b098xbcf0d308195ff584@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.233 tagged_above=0 required=5 tests=AWL, BAYES_50, FORGED_RCVD_HELO X-Spam-Level: X-Archive-Number: 200702/165 X-Sequence-Number: 24630 Ezequias Rodrigues da Rocha wrote: > 2007/2/12, Richard Huxton : >> >> Ezequias Rodrigues da Rocha wrote: >> > I mean really deadlock. Other transactions can't access the database >> until >> > the main transaction is complete. A question: >> > >> > PostgreSQL doesn't permit multiple transactions concurrently ? >> >> PG has quite good concurrency behaviour. And "can't access the database" >> isn't anything to do with locking - clients should still be able to log >> in. >> >> We'll need more details: >> 1. How do you know this is a deadlock? You haven't shown us what's in >> pg_locks, but I assume you've identified the problem there. > > > I knew becouse my Delphi application reports it to me. If there is anything > in pg_log I could see it to you. You still aren't showing us the deadlock in pg_locks. How does your Delphi application decide there is a deadlock? I can see how it might know a timeout has occurred, but not how it determines what any other connections to the database might be doing. You do know the difference between just waiting for locks and having a deadlock? http://en.wikipedia.org/wiki/Deadlock > 2. What data are you loading, to what tables? > > Simple data but allways with the same username (does it make any difference > ?) > > 3. Are there any foreign-keys or triggers we would need to know about? > > No. Then you don't have a deadlock. Without multiple processes trying to take the same locks in different orders you don't get deadlock. > Ps: When I do not use transactions the connections does not lock to other > users. You are always using transactions. There is no out-of-transaction way to execute a statement in PostgreSQL. You can't lock either a connection or users, just rows. OK - I think you'd better give a full example. Can you show us: 1. What query or queries you execute to load the data? 2. What query or queries you think are causing "deadlock"? 3. The order they execute in and what error you get. -- Richard Huxton Archonet Ltd