Deadlock on the same object?

From: Itagaki Takahiro <itagaki(dot)takahiro(at)oss(dot)ntt(dot)co(dot)jp>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Deadlock on the same object?
Date: 2009-11-11 03:03:13
Message-ID: 20091111120313.445E.52131E4D@oss.ntt.co.jp
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

I encountered the following log in 8.4.1 and HEAD. The deadlock occured
on the same object (relation 17498 of database 17497). Is it reasonable?

ERROR: deadlock detected
DETAIL: Process 6313 waits for ExclusiveLock on relation 17498 of database 17497; blocked by process 6312.
Process 6312 waits for ExclusiveLock on relation 17498 of database 17497; blocked by process 6313.
Process 6313: SELECT test()
Process 6312: SELECT test()
HINT: See server log for query details.
CONTEXT: SQL function "test" statement 1
STATEMENT: SELECT test()

(relation 17498 is table 'a')

A reproducible test set is:
----
CREATE TABLE a (i integer PRIMARY KEY);
CREATE TABLE b (i integer REFERENCES a(i));

CREATE FUNCTION test() RETURNS VOID AS
$$
LOCK a IN EXCLUSIVE MODE;
LOCK b IN EXCLUSIVE MODE;
DELETE FROM a;
$$
LANGUAGE sql STRICT;
----

# Repeat the following commands in shell.
psql -c "SELECT test()" &
psql -c "SELECT test()" &
psql -c "SELECT test()" &
wait

Regards,
---
ITAGAKI Takahiro
NTT Open Source Software Center

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Josh Berkus 2009-11-11 04:14:45 Re: Parsing config files in a directory
Previous Message Tom Lane 2009-11-10 23:15:19 Re: [HACKERS] PostgreSQL 8.3.8 on AIX5.3 : compilation failed