Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deadlock problem

Status
Not open for further replies.

ketankshah

IS-IT--Management
Jan 11, 2001
121
IN
I am sometimes getting deadlock error on my customer's e-commerce website.

Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Microsoft][ODBC SQL Server Driver][SQL Server]Transaction (Process ID 73)
was deadlocked on lock resources with another process and has been chosen as the deadlock victim. Rerun the transaction.
/secure/shopcart.asp, line 405

How can I sort out this error?

Thanks

Ketan
 
Check the following links from SQL BOL.



If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Dead lock, as you may be knowing happens when a process is trying to access an object locked by another process. One way to avoid this by using uncommited read when ever snap Shot data is sufficient.

For ex. you can say

SELECT * FROM tblProduct WITH (NOLOCK) WHERE ....

This will fetch data from Product table which have been updated in the table but may not have been commited as yet. This is called dirty read.

Typically this may not be acceptable in case of critical data(like financial transactions). But in most other scenario this should be OK.

 
Kutty, actually deadlock is a bit more complicated.
In your scenario the lock problem will disapear once the first process (the one that has a lock) has finished this is not a deadlock although the 2nd process may timeout waiting for the first to finish.

A deadlock is when there are two or more processes in the following setup.

Process 1 has table A locked and needs table B to finish.

Process 2 has table B locked and needs table A to finish.

Since neither process can finish you have a deadlock. The server then picks a process to kill which is the only way out of a deadlock.

Usually deadlock are caused by creating transactions that use a large number of tables and run for a long time. By carefully monitoring what processes are running when a deadlock occurs you can generally identify them and modify the code to avoid the problem.



 
Fluteplr is correct regarding deadlocks. That is the reason I directed Ketan to SQL BOL. BOL contains a more detailed explanation as well as strategies for avoiding deadlocks. If you want to get the best answer for your question read faq183-874 and faq183-3179.
Terry L. Broadbent - DBA
SQL Server Page:
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top