Deadlock on the same object? - Mailing list pgsql-hackers

From Itagaki Takahiro
Subject Deadlock on the same object?
Date
Msg-id 20091111120313.445E.52131E4D@oss.ntt.co.jp
Whole thread Raw
Responses Re: Deadlock on the same object?
List 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.
Process6312 waits for ExclusiveLock on relation 17498 of database 17497; blocked by process 6313.       Process 6313:
SELECTtest()       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



pgsql-hackers by date:

Previous
From: Tom Lane
Date:
Subject: Re: [GENERAL] PostgreSQL 8.3.8 on AIX5.3 : compilation failed
Next
From: Josh Berkus
Date:
Subject: Re: Parsing config files in a directory