If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Question from Deadlock Chain

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 08-24-09, 11:51
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Question from Deadlock Chain

Env: DB2 8.2/AIX 5.3

Lock snapshot shows the following information but I am not sure what would have caused this deadlock. Any thought on this?

Quote:
HOLD_APP HOLDER_ID HOLDER WAIT_APP WAITING_ID WAITER HOLD_MODE OBJ_TYPE TAB_NAME SCHEMA WAIT_TIME CUR_TIME
---------- ----------- ---------- ---------- ----------- ---------- --------- -------- --------------- ---------- ----------- --------
db2jcc_app 9285 APPOWNER db2jcc_app 9283 APPOWNER X Row TAB1 ETL 0 11:23:02
db2jcc_app 9283 APPOWNER db2jcc_app 9285 APPOWNER NKS Row TAB2 ETL 0 11:23:02
Reply With Quote
  #2 (permalink)  
Old 08-24-09, 11:58
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You need to look EVERYWHERE in the app where Tab1 and Tab2 are both modified. They should be modified in the same order (e.g. Tab1, then Tab2). Somewhere in the application the order is backwards. This is what needs fixing.

Andy
Reply With Quote
  #3 (permalink)  
Old 08-24-09, 12:28
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
You need to look at the deadlock event monitor output - the monitor should be running by default, unless you dropped or disabled it. The name is DB2DETAILDEADLOCK.
Reply With Quote
  #4 (permalink)  
Old 08-24-09, 12:39
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
DB2DETAILEDDEADLOCK has been disabled so that is not helping me here.

By the way, how are you saying that it should be modified in same order to avoid this deadlock ? I would appreciate if you can provide more info on this.

In my understanding of Regarding Next Key Share lock this is obtained for rows on the same index page if CS or RS isolation level is used. For example if a table has 500 rows (50 rows per page). If a rows in updated with X lock rest of 49 rows on the same page will have NKS lock. Is this a correct understanding ? Would you pls correct me if I'm wrong.
Reply With Quote
  #5 (permalink)  
Old 08-24-09, 14:14
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
You are using V8 which is long out of service, and I do not remember how the locking works. But it really does not matter. What is happening is this:

Application A is locking a resource on Tab1
Application B is locking a resource on Tab2
Application A wants to lock the same resource on Tab2 but cannot so it goes to lock wait
Application B want to lock the resource on Tab1 <<-- DB2 detects a deadlock with this.

It does not matter what the lock types are specifically. You need to determine what statements are causing the deadlock. The previously mentioned event monitor will provide that. Then the application need to be changed so that the order is changed. In the example, change Application B to try to access Tab1 first then Tab2.

Andy
Reply With Quote
  #6 (permalink)  
Old 08-24-09, 16:15
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Thanks for sharing this. I am enabling deadlock event monitor to find the needle from the deadlock haystack.
Reply With Quote
  #7 (permalink)  
Old 08-24-09, 16:37
rdutton rdutton is offline
Registered User
 
Join Date: Dec 2008
Posts: 76
Once you have determined the deadlocking statements, sometimes you can prevent deadlocks with better indexes. If one or both statements are doing a tablespace scan, an index that will prevent the scan may avoid the deadly embrace. I emphasize: sometimes.
__________________
RD
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On