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

Upgrade to UBER TABLE LOCK #30

Merged
merged 1 commit into from
May 16, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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