Re: How do I interpret the data returned from a DeadLock-Exception?(Java)

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Øyvind Møller Asbjørnsen <oyvindma(at)tihlde(dot)org>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: How do I interpret the data returned from a DeadLock-Exception?(Java)
Date: 2006-02-03 15:21:45
Message-ID: 26301.1138980105@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

=?ISO-8859-1?Q?=D8yvind_M=F8ller_Asbj=F8rnsen?= <oyvindma(at)tihlde(dot)org> writes:
> My java-application is producing dead locks quite frequently, and I
> would like to resolve them. How do I interpret the data in the error
> message? Are there any ways of finding out e.g what process 3224 is and
> what it is doing? Which relation is nr 16409? what is tuple(0,25) and so
> on. Any nice tools one could use?

Well, you find out which database that is with
select datname from pg_database where oid = 16409;
then you go into that database and find out the table involved with
select relname from pg_class where oid = 30425;
and if you need to know the particular row then you go
select * from that-table where ctid = '(0,25)';
However, what's probably going to be more interesting is to figure out
what SQL commmands are generating these errors. If your application
doesn't give you any help with that then look in the postmaster log
(you may need to adjust the setting of log_min_error_statement).

> Detail: Process 3224 waits for ExclusiveLock on tuple (0,25) of relation
> 30425 of database 16409; blocked by process 2632.
> Process 2632 waits for ShareLock on transaction 96197; blocked by
> process 2488.
> Process 2488 waits for ExclusiveLock on tuple (0,25) of relation 30425
> of database 16409; blocked by process 3224.

This looks a little odd because as far as I can see, the first two lines
imply that process 2488 has already modified the row in question ... so
why does it need to take the row lock again?

When you've worked out which commands are producing the deadlock, if
it's not obvious to you that you did something wrong, please post the
details.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Murat Tasan 2006-02-03 16:27:47 Re: function privileges
Previous Message Arnaud Lesauvage 2006-02-03 14:20:10 Re: Create table and update it within one function ?