Solved

how to get the deadlock graph in postgres

Posted on 2011-03-14
4
1,002 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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

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.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

680 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