什么是数据库中的死锁? [英] what is deadlock in a database?

查看:213
本文介绍了什么是数据库中的死锁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么是sql server中的死锁,什么时候出现?什么是死锁的问题和如何解决它?

What is deadlock in sql server and when it arises? What are the issues with deadlock and how to resolve it?

推荐答案

通常,死锁意味着两个或多个实体阻塞一些源,而且没有一个能够完成,因为它们以循环方式阻塞源。

In general, deadlock means that two or more entities are blocking some sources, and none of them is able to finish, because their are blocking sources in a cyclic way.

一个例子:假设我有表A和表B,我需要在A中做一些更新,然后B和I决定在使用的时候锁定他们(这是真的愚蠢的行为,但它现在服务它的目的)。在同一时刻,其他人以相反的顺序做同样的事情 - 先锁定B,然后锁定A.

One example: Let's say I have table A and table B, I need to do some update in A and then B and I decide to lock both them at the moment of usage (this is really stupid behaviour, but it serves it's purpose now). At the same moment, someone else does the same thing in opposite order - locks B firstly, then locks A.

按时间顺序,发生这种情况:

Chronologically, this happens:

proc1:Lock A
proc2:Lock B

proc1: Lock A proc2: Lock B

proc1:Lock B - 开始等待直到proc2释放B
proc2:Lock A - 开始等待直到proc1释放A

proc1: Lock B - starts waiting until proc2 releases B proc2: Lock A - starts waiting until proc1 releases A

很明显,他们都不会完成。这是死锁。

It's obvious neither of them will finish. That's deadlock.

洞更深,但这只是进入,如果你需要知道更多,投入你的时间。在我们的大学有关于这一点的所有讲座 - 所以不要认为阅读几篇文章使你成为一个专家; - )

The hole goes much deeper, but this is just entry and if you need to know more, invest your time. In our university there are whole lectures about that - so don't think that reading few articles makes you an expert ;-)

这篇关于什么是数据库中的死锁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆