Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Avoiding deadlock
Message
From
12/10/2014 13:14:35
 
 
To
12/10/2014 12:34:25
General information
Forum:
Microsoft SQL Server
Category:
Other
Environment versions
SQL Server:
SQL Server 2012
Application:
Web
Miscellaneous
Thread ID:
01609189
Message ID:
01609191
Views:
55
>UPDATE Member SET LastAccess=@LastAccess WHERE Numero=@Numero
>
>
>This update on the Member table can only be done by one person. So, there cannot be two updates done on that record at the same time. Why do I end up with a deadlock on some isolated situations?

Michel, this is something where utilizing SQL Profiler might help (or some other event-based approach to monitor what statements are occurring), to see what actually is going on.

If only one update can happen, my guess is that there is some read process going on at the same time. And maybe that read process is taking a while to occur.

If I do this...

SELECT * FROM Member where Numero = @Numero

And for whatever reason, that query takes a good while to run, that places a read (shared) lock on the row. That prevents other processes from issuing a write lock on the same row.

You might want to check if there are any locked processes against the database. But either way.....for an UPDATE to occur,, SQL Server needs to be able to issue a write lock. And that is not possible if there are read locks on the row at the same time.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform