[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1089
  • Last Modified:

how to get the deadlock graph in postgres

HI
I would like to know how to get the deadlock graph in postgres when a deadlock occurs.

Thanks
0
elimesika
Asked:
elimesika
  • 3
2 Solutions
 
earth man2Commented:
select * from pg_locks;
0
 
elimesikaAuthor Commented:
Thanks :earthman2

That is obvious, but what am I looking for is :
1) The list of nodes involved in the  deadlock.
2) The SQL statement each node was trying to process when the deadlock occurred.
3) The process that was chosen by the DB as a victim.

How can I get that information ?

Thanks
0
 
elimesikaAuthor Commented:
Well ,just to share the solution:

Postgres 8.4 added deadlock graph info to the server log
see
"When reporting a deadlock, report the text of all queries involved in the deadlock to the server log (Itagaki Takahiro) "
in
http://www.postgresql.org/docs/8.4/static/release-8-4.html#RELEASE-8-4-PG-HBA-CONF
The reason that I didn'r got that in my log was that I was using an EXCEPTION block on OTHERS.
That includes of course the DEADLOCK_DETECTED SQLSTATE value and masked the default behaviour.
so, to get the info, let postgres trap the deadlock and handle it.

such simple ....


0
 
elimesikaAuthor Commented:
I have found the solution by myself.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now