Skip to content
This repository has been archived by the owner on Sep 5, 2018. It is now read-only.

Commit

Permalink
Merge pull request #30 from NuGet/anurse/2151-howdoisql
Browse files Browse the repository at this point in the history
Upgrade to UBER TABLE LOCK
  • Loading branch information
analogrelay committed May 16, 2014
2 parents 4151650 + 0c2e3c0 commit 776c513
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
)
AS
-- Find an available row to dequeue and insert a new one indicating it has been dequeued
-- * We use a tablockx below because we want the whole darn table locked while we do this to prevent double-dequeue
-- There are probably finer-grain locks we could take but this is the easiest way
WITH cte
AS (
SELECT TOP (1) *
FROM [work].ActiveInvocations
FROM [work].ActiveInvocations WITH (tablockx) -- MEGA LOCK!*
WHERE [NextVisibleAt] <= SYSUTCDATETIME()
AND Complete = 0
ORDER BY [NextVisibleAt]
Expand Down

0 comments on commit 776c513

Please sign in to comment.