Avoiding deadlock by using NOLOCK hint

前端 未结 3 1042
野趣味
野趣味 2021-02-06 00:18

Once in a while I get following error in production enviornment which goes away on running the same stored procedure again.

Transaction (Process ID 86) wa

3条回答
  •  半阙折子戏
    2021-02-06 00:50

    While adding NOLOCK can prevent readers and writers from blocking each other (never mind all of the negative side effects it has), it is not a magical fix for deadlocks. Many deadlocks have nothing at all to do with reading data, so applying NOLOCK to your read queries might not cause anything to change at all. Have you run a trace and examined the deadlock graph to see exactly what the deadlock is? This should at least let you know which part of the code to look at. For example, is the stored procedure deadlocking because it is being called by multiple users concurrently, or is it deadlocking with a different piece of code?

提交回复
热议问题