记录锁定处理 [英] record locking handling

查看:90
本文介绍了记录锁定处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我在sql服务器的行/记录上创建了Rowlock以进行更新.

这样我一次只允许一个人更新一条记录.

因此,当另一个用户(第二个用户)尝试读取同一条记录时,它会抛出"超时超时异常",而不是抛出确切的异常(需要行锁定异常).

请告诉我如何处理行锁异常.

Hi,

I have created Rowlock on a row/record of sql server for updating.

So that i will allow only one person to update a record at a time.

So when another user(2nd user)try''s to read same record it is throwing "TimeOut out exception" instead of throwing exact exception(Needed row lock exception).

Please tell me how to handle row lock exception please.

推荐答案

事务将等待,直到行上的锁被解除或连接超时为止.

如果超时,则说明您的数据库使用不当,并且锁定行的时间超过了几毫秒.这是不好.

事务和锁定应尽可能短.
Transactions will wait until the lock has been lifted on the row or a connection time out is reached.

If you are getting timeouts then you are using your database badly and locking rows for extended periods greater than a few milliseconds. This is bad.

Transactions and locking should be as short as possible.


这篇关于记录锁定处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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