Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VH9B6-0008Pf-Nl for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Sep 2013 09:15:08 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VH9B6-0000PQ-1x for pgsql-bugs@arkaria.postgresql.org; Wed, 04 Sep 2013 09:15:08 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VH9B5-0000Ov-4T for pgsql-bugs@postgresql.org; Wed, 04 Sep 2013 09:15:07 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by magus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VH9Az-0006Pe-V8 for pgsql-bugs@postgresql.org; Wed, 04 Sep 2013 09:15:06 +0000 Received: from [204.145.124.246] (helo=wrigleys.postgresql.org) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VH9Az-0007YC-4c for pgsql-bugs@postgresql.org; Wed, 04 Sep 2013 09:15:01 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VH9At-0005VC-Kk for pgsql-bugs@postgresql.org; Wed, 04 Sep 2013 09:14:55 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8434: Why does dead lock occur many times ? To: pgsql-bugs@postgresql.org From: katsumata.tomonari@po.ntts.co.jp Message-Id: Date: Wed, 04 Sep 2013 09:14:55 +0000 X-Pg-Spam-Score: -4.3 (----) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8434 Logged by: Tomonari Katsumata Email address: katsumata.tomonari@po.ntts.co.jp PostgreSQL version: 9.3rc1 Operating system: RedHatEnterpriseLinux 6.4(x86_64) Description: Hi, I'm testing PostgreSQL 9.3rc1. Many times updates and selects for update become dead lock situation. The reproduce is: 1. initializing data createdb testdb psql testdb -c "create table t (col1 int, col2 int, col3 text);" psql testdb -c "insert into t values (1, 4, 'A');" psql testdb -c "insert into t values (2, 5, 'B');" psql testdb -c "insert into t values (3, 6, 'C');" 2. executing updates and selects for update (run below script) ---- #!/bin/sh ./tx1 > /dev/null & ./tx2 > /dev/null & ./tx3 > /dev/null & wait ---- tx1 is: ---- #!/bin/sh while : do psql testdb << EOF BEGIN; UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; COMMIT; \q EOF done ---- tx2 is: ---- #!/bin/sh while : do psql testdb << EOF BEGIN; SELECT col1, col2, col3 FROM t WHERE col1 = 3 AND col2 = 6 FOR UPDATE; UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; COMMIT; \q EOF done ---- tx3 is: ---- #!/bin/sh while : do psql testdb << EOF BEGIN; UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; COMMIT; \q EOF done ---- Then, I got below messages. -------- 2013-09-04 15:25:25 JST 29630 5226d254.73be-1 659102 (pgsql, testdb, [local], psql) LOG: 00000: process 29630 detected deadlock while waiting for ShareLock on transaction 659103 after 1000.136 ms 2013-09-04 15:25:25 JST 29630 5226d254.73be-2 659102 (pgsql, testdb, [local], psql) LOCATION: ProcSleep, proc.c:1232 2013-09-04 15:25:25 JST 29630 5226d254.73be-3 659102 (pgsql, testdb, [local], psql) STATEMENT: UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; 2013-09-04 15:25:25 JST 29630 5226d254.73be-4 659102 (pgsql, testdb, [local], psql) ERROR: 40P01: deadlock detected 2013-09-04 15:25:25 JST 29630 5226d254.73be-5 659102 (pgsql, testdb, [local], psql) DETAIL: Process 29630 waits for ShareLock on transaction 659103; blocked by process 29631. Process 29631 waits for ExclusiveLock on tuple (0,153) of relation 16385 of database 16384; blocked by process 29630. Process 29630: UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; Process 29631: UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; 2013-09-04 15:25:25 JST 29630 5226d254.73be-6 659102 (pgsql, testdb, [local], psql) HINT: See server log for query details. 2013-09-04 15:25:25 JST 29630 5226d254.73be-7 659102 (pgsql, testdb, [local], psql) LOCATION: DeadLockReport, deadlock.c:956 2013-09-04 15:25:25 JST 29630 5226d254.73be-8 659102 (pgsql, testdb, [local], psql) STATEMENT: UPDATE t SET col3 = 'c' WHERE col1 = 3 AND col2 = 6; -------- I did not get these messages with PostgreSQL 9.2.4. Why did I get the dead lock situation with PostgreSQL9.3rc1? degrading? or I'm missing something? regards, ------------ Tomonari Katsumata -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs