Solved

how to get the deadlock graph in postgres

Posted on 2011-03-14
4
997 Views
Last Modified: 2012-08-14
HI
I would like to know how to get the deadlock graph in postgres when a deadlock occurs.

Thanks
0
Comment
Question by:elimesika
  • 3
4 Comments
 
LVL 22

Expert Comment

by:earth man2
ID: 35152818
select * from pg_locks;
0
 
LVL 19

Assisted Solution

by:elimesika
elimesika earned 0 total points
ID: 35181437
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
 
LVL 19

Accepted Solution

by:
elimesika earned 0 total points
ID: 35187958
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
 
LVL 19

Author Closing Comment

by:elimesika
ID: 35225135
I have found the solution by myself.
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Postgresql error 57014 5 430
case statement in complex SQL 9 205
Remove duplicates in a time range? 14 120
A beginner asks: Which macos postgreSQL client? 5 56
Best database to use for Maps is PostgreSQL. This is an open source database. Comes as a package with most Linux OS. For more info visit the following site: http://www.postgresql.org/ (http://www.postgresql.org/) This requires some add-o…
Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question