Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Avoiding deadlock
Message
De
12/10/2014 13:14:35
 
 
À
12/10/2014 12:34:25
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Versions des environnements
SQL Server:
SQL Server 2012
Application:
Web
Divers
Thread ID:
01609189
Message ID:
01609191
Vues:
56
>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.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform