互斥存储过程
我想使用数据库表创建一些分布式互斥。 如果存储过程具有以下接口,那就太好了:
Wait(uniqueidentifier)
我最初考虑通过拥有唯一标识符表来实现此功能。 对该过程的调用将等到表中不存在唯一标识符为止。 但是,我不确定当从表中删除指定的唯一标识符时如何唤醒调用线程。
有任何想法吗? 如果数据库不是执行此操作的正确位置,是否有任何可以使用的第三方工具(最好是开源的)?
(为了避免死锁,我要么想在等待操作中包含超时,要么让 SqlCommand 有超时)
I want to create some distributed mutual exclusion using a database table. It would be nice to have the following interface on a stored procedure:
Wait(uniqueidentifier)
I was originally thinking of implementing this by having a table of unique identifiers. A call to the procedure would wait until the unique identifier does not exist in the table. However, I'm not sure how I would make the calling thread wake up when the specified unique identifier was removed from the table.
Any ideas? If the database is not the right place to do this, are there any third party tools that would work (open source preferably)?
(To avoid deadlocks, I either want to include a timeout in the wait operation or have the SqlCommand have a timeout)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看一下系统存储过程:
它可能会帮助您完成您想要做的事情。
http://msdn.microsoft.com/en-us/library/ms189823。 aspx
您可以将其放入参数化 uniqueidentifier 的过程中...
Take a look at the system stored procedure:
It may help you accomplish what you are trying to do.
http://msdn.microsoft.com/en-us/library/ms189823.aspx
You can put it in a proc that parametrizes the uniqueidentifier...