SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


deadlock


deadlock

Author
Message
sandhyarao49
sandhyarao49
SSC Eights!
SSC Eights! (859 reputation)SSC Eights! (859 reputation)SSC Eights! (859 reputation)SSC Eights! (859 reputation)SSC Eights! (859 reputation)SSC Eights! (859 reputation)SSC Eights! (859 reputation)SSC Eights! (859 reputation)

Group: General Forum Members
Points: 859 Visits: 650
If we have a Dead lock situation,we can check in the error log and find out which spids are involved in the process.After that the next step is to kill one of the process by using KILL (spid)

In this situation i have a small doubt can we able to directly issue a kill command.Is this approach correct one or any other solution is there.
And i want to know can we have to consider anything before issuing a
kill command.
Is this is the only solution or is there any approach.
And i have one more doubt , if we kill a process then what about the data that the transaction is processing

Plz guide me.
Jack Corbett
  Jack Corbett
SSC Guru
SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)SSC Guru (86K reputation)

Group: General Forum Members
Points: 86969 Visits: 14997
There are a couple of things I would do before killing a process.

1. Run sp_lock [spid] for each spid to see what is object(s) are causing the deadlock and the types of locks. You will see a wait for the blocked spid.
2. Run DBCC InputBuffer([spid]) for each spid involved to find the statements that are causing the deadlock.

Once you find this you can then determine if indexing may help (possibly reduce the type of lock from table to page/row), refactor the code in the offending statements to access tables in the same order, and determine there are long-running transactions that can be broken down in to smaller transactions.



Jack Corbett

Applications Developer

Don't let the good be the enemy of the best. -- Paul Fleming
At best you can say that one job may be more secure than another, but total job security is an illusion. -- Rod at work

Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
How to Post Performance Problems
Crosstabs and Pivots or How to turn rows into columns Part 1
Crosstabs and Pivots or How to turn rows into columns Part 2
MANU-J.
MANU-J.
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14760 Visits: 8766
In case you have recurring deadlock issues then go thru the link mentioned below and you really dont knwo how to troubleshoot them:

http://blogs.msdn.com/bartd/archive/2006/09/09/Deadlock-Troubleshooting_2C00_-Part-1.aspx

Manu Jaidka
GilaMonster
GilaMonster
SSC Guru
SSC Guru (460K reputation)SSC Guru (460K reputation)SSC Guru (460K reputation)SSC Guru (460K reputation)SSC Guru (460K reputation)SSC Guru (460K reputation)SSC Guru (460K reputation)SSC Guru (460K reputation)

Group: General Forum Members
Points: 460322 Visits: 47313
If you have a true deadlock, then you won't need to kill processes. SQL has a deadlock detector that will notice a deadlock condition, pick one of the participants and kill it automatically.

Do you have true deadlocks (if so, the users will be getting occasional errors about processes been picked as the deadlock victim and rolled back) or do you just have long-term blocking?

Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass


mobasha
mobasha
SSCrazy
SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)SSCrazy (2.7K reputation)

Group: General Forum Members
Points: 2688 Visits: 1284
if u killed a process its statment will be rolled back, so u dont have to wory that much.
but if the code have "begin transaction and commit transaction" if u killed the session after the commit then the roll back wont effect this batch.

..>>..

MobashA
alimcitp
alimcitp
Mr or Mrs. 500
Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)Mr or Mrs. 500 (510 reputation)

Group: General Forum Members
Points: 510 Visits: 344
You dont need to kill the process because SQL Server automatically kills the process that is creating that deadlock by using its internal deadlock manager.

Basit Ali Farooq
MCITP Database Administrator
Microsoft Certified Professional Developer (Web Applications)
Microsoft Certified Database Administrator
Microsoft Certified Systems Engineer
Microsoft Certified Systems Administrator
CIW Security Analyst
Cisco Certified Network Associate

Avishkar Meshram
Avishkar Meshram
SSC Veteran
SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)SSC Veteran (232 reputation)

Group: General Forum Members
Points: 232 Visits: 326
To avoid deadlock, you must have through knowledge of your application.
1. Identify the deadlocking processes and the object sparticipating in deadlock.
2. Use program monitoring table, say Program_session having columns program_id and running_date and modify your SPs/or queries such that, it will first check entry in Program_session and verify if running_date is NULL.
3. If running_date is NULL, then SP can continue with setting running_date to getdate(). And after executing set running_date to NULL.
4. Else use wait() command to follow steps 3.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search