[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

how to get the deadlock graph in postgres

Posted on 2011-03-14
4
Medium Priority
?
1,076 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
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.
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month18 days, 21 hours left to enroll

834 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