Thursday, November 27, 2014

Deadlock



Question: How can I trace and capture DB2 database deadlock details? I then want to  view the deadlock details.
Answer: Capturing DB2 deadlock details is straightforward. Use a similar process to below. Basically, you create an Event Monitor , capture some activity into a file, drop the event monitor.

#connect to db
#1-Create event monitor- make sure you've got write permissions
db2 "CREATE EVENT MONITOR dlmon FOR DEADLOCKS WRITE TO FILE '/tmp'"
#2 Turn on event monitordb2
SET EVENT MONITOR dlmon STATE = 1
#3. Turn off event monitordb2 
SET EVENT MONITOR dlmon STATE = 0
#4. Translate event monitor into readable stuff
db2evmon -path /tmp > /tmp/filtered.out
#5. Read the events
vi /tmp/filtered.out
#6. drop
db2 DROP EVENT MONITOR dlmon 



No comments:

Post a Comment