死锁:Transaction (Process ID) was deadlocked on lock resources with another process and has been chose
死锁:Transaction (Process ID) was deadlocked on lock resources with another process and has been chose
讲故事
最近新开发了一个接口,需要对一个表进行循环增删改查,在进行更新的时候反复报错:Transaction (Process ID) was deadlocked on lock resources with another process and has been chose;
百思不得其解,原来程序都是这么写的,都没有问题,这是为什么呢
真因
未设置索引导致数据库死锁!
代码是根据GUID来进行更新操作的,而GUID又没有索引,汗
解决
将GUID字段加入索引,问题解决