Home All Groups Group Topic Archive Search About

how to solve deadlock issue

Author
23 Dec 2005 10:18 AM
Deepu
Hi,



In our application we are getting a deadlock error “transaction  (process
id)  was deadlocked on (lock) resources with another process and has been
chosen as the deadlock victim”

When we traced the queries in sql profiler we were able to find out  two
queries trying to access the same table.



The given below are the queries



1.      Update customer (rowlock) set column1 = ‘1’ where customercd =
‘xxxx’.                start time = ‘2005-12-23 11:43:47:250’

2.      Update customer (rowlock) set routecd = ‘xx’ from customer left
outer join table2 csc  on Customer.CustomerCD = CSC.CustomerCD     where
CSC.CustomerCD is Null         and Customer.RouteCD is Not Null.             
                                               Start time = ‘2005-12-23
11:43:53:883



Both the queries are executed from two different machines.

After this the first query became the victim of the deadlock.



Can any one suggest some way to overcome this issue??



Thanks

Deepu

Author
23 Dec 2005 11:05 AM
ML
Author
23 Dec 2005 1:32 PM
amish
Author
23 Dec 2005 2:18 PM
Dan Guzman
The likelihood of deadlocks increases with poor performance and long running
transactions.  Please post complete table DDL, including indexes.

If CustomerCD is the primary key of the customer table, I would expect the
first query to run very quickly and the rowlock hint not needed since only
one row will possibly be retrieved.  However, since the second query started
abut 5 seconds later than the first, either the query was still running or
there is an open transaction on the first connection.  Both cases are red
flags that need to be investigated.

Similarly, a indexes on the columns in the JOIN and WHERE clauses of the
second query may help.

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Deepu" <De***@discussions.microsoft.com> wrote in message
news:892BDC17-4F1A-4715-83EB-006D8A450765@microsoft.com...
> Hi,
>
>
>
> In our application we are getting a deadlock error "transaction  (process
> id)  was deadlocked on (lock) resources with another process and has been
> chosen as the deadlock victim"
>
> When we traced the queries in sql profiler we were able to find out  two
> queries trying to access the same table.
>
>
>
> The given below are the queries
>
>
>
> 1.      Update customer (rowlock) set column1 = '1' where customercd =
> 'xxxx'.                start time = '2005-12-23 11:43:47:250'
>
> 2.      Update customer (rowlock) set routecd = 'xx' from customer left
> outer join table2 csc  on Customer.CustomerCD = CSC.CustomerCD     where
> CSC.CustomerCD is Null         and Customer.RouteCD is Not Null.
>                                               Start time = '2005-12-23
> 11:43:53:883
>
>
>
> Both the queries are executed from two different machines.
>
> After this the first query became the victim of the deadlock.
>
>
>
> Can any one suggest some way to overcome this issue??
>
>
>
> Thanks
>
> Deepu
>
>
>
>
>

AddThis Social Bookmark Button