X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 359CED7AFD for ; Mon, 29 Aug 2005 14:26:15 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 43630-01 for ; Mon, 29 Aug 2005 17:26:10 +0000 (GMT) Received: from anchor-post-34.mail.demon.net (anchor-post-34.mail.demon.net [194.217.242.92]) by svr1.postgresql.org (Postfix) with ESMTP id 1BB89D7793 for ; Mon, 29 Aug 2005 14:26:06 -0300 (ADT) Received: from lfix.demon.co.uk ([80.177.205.209] helo=cerberus.lfix.co.uk) by anchor-post-34.mail.demon.net with esmtp (Exim 4.42) id 1E9nOY-000FjC-FZ; Mon, 29 Aug 2005 17:26:06 +0000 Received: from linda.lfix.co.uk ([192.168.1.1]) by cerberus.lfix.co.uk with esmtp (Exim 4.50) id 1E9nOQ-0004YL-1y; Mon, 29 Aug 2005 18:25:58 +0100 Subject: Re: Query failed: ERROR: deadlock detected From: Oliver Elphick Reply-To: olly@lfix.co.uk To: Aldor Cc: pgsql-admin@postgresql.org In-Reply-To: <43132ED4.9000107@mediaroot.de> References: <43132ED4.9000107@mediaroot.de> Content-Type: text/plain Organization: LFIX Limited Date: Mon, 29 Aug 2005 18:25:57 +0100 Message-Id: <1125336357.2589.8.camel@linda> Mime-Version: 1.0 X-Mailer: Evolution 2.2.3 Content-Transfer-Encoding: 7bit X-LFIX-MailScanner: Found to be clean X-LFIX-MailScanner-SpamCheck: not spam, SpamAssassin (score=-5.899, required 5, autolearn=not spam, ALL_TRUSTED -3.30, BAYES_00 -2.60) X-LFIX-MailScanner-From: olly@lfix.co.uk X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.048 required=5 tests=[AWL=-0.002, FORGED_RCVD_HELO=0.05] X-Spam-Level: X-Archive-Number: 200508/371 X-Sequence-Number: 18690 On Mon, 2005-08-29 at 16:50 +0100, Aldor wrote: > PostgreSQL 8.0.3: Any idea what this is? > > --- > Warning: pg_query(): Query failed: ERROR: deadlock detected > DETAIL: Process 8835 waits for ShareLock on transaction 193588236; > blocked by process 8834. > Process 8834 waits for ShareLock on transaction 193588228; blocked by > process 8835 > --- > > I have never seen such a log entry until now. You have two transactions locking each other out. For example: trans A: begin; trans B: begin; trans A: select * from table_a for update; -- locks table_a trans B: select * from table_b for update; -- locks table_b trans A: select * from table_b for update; -- blocked by trans B's lock trans B: select * from table_a for update; -- blocked by trans A's lock Since the two transactions are blocking each other, the locks will never be released by the transactions that are holding them. After a preset interval (about 1 second by default) a deadlock is detected and reported with this error message and one of the transactions is aborted. See manual section 12.3.3 in the 8.0 documentation. -- Oliver Elphick olly@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver GPG: 1024D/A54310EA 92C8 39E7 280E 3631 3F0E 1EC0 5664 7A2F A543 10EA ======================================== Do you want to know God? http://www.lfix.co.uk/knowing_god.html