ITPub博客

首页 > 应用开发 > IT综合 > Avoid Deadlocks (339)

Avoid Deadlocks (339)

原创 IT综合 作者:tsinglee 时间:2007-12-10 11:44:48 0 删除 编辑

Multitable deadlocks can usually be avoided if transactions accessing the same tables
lock those tables in the same order, either through implicit or explicit locks. For
example, all application developers might follow the rule that when both a master and
detail table are updated, the master table is locked first and then the detail table. If
such rules are properly designed and then followed in all applications, deadlocks are
very unlikely to occur.

When you know you will require a sequence of locks for one transaction, consider
acquiring the most exclusive (least compatible) lock first.

避免死锁
1. 如果事务按相同的顺序对相同的表加锁(隐式或显式),通常都能避免多表死锁
2. 当预先知道一个事务内需要获取一系列的锁时 , 可以考虑先获取排他性最高的锁

[@more@]

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/10599713/viewspace-990927/,如需转载,请注明出处,否则将追究法律责任。

下一篇: Types of Locks (340)
请登录后发表评论 登录
全部评论
  • 博文量
    740
  • 访问量
    1892746