SQL Server Process Queue Race Condition

前端 未结 2 1283
既然无缘
既然无缘 2020-11-22 13:07

I have an order queue that is accessed by multiple order processors through a stored procedure. Each processor passes in a unique ID which is used to lock the next 20 orders

2条回答
  •  独厮守ぢ
    2020-11-22 13:49

    You can use Service Broker. Also you can use sp_getapplock to serialize access to your rows - that will eliminate race conditions:

    "Assisting Concurrency by creating your own Locks (Mutexs in SQL) " http://sqlblogcasts.com/blogs/tonyrogerson/archive/2006/06/30/855.aspx

提交回复
热议问题