You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/DistributedLock.SqlServer/SqlSemaphore.cs
+6-6Lines changed: 6 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -331,7 +331,7 @@ FROM tempdb.sys.tables WITH(NOLOCK)
331
331
{C/* Prefix search here is important since it uses an index. We don't need escaping because we bound the name to use a fixed character set */}
332
332
WHERE name LIKE '##' + @{SemaphoreNameParameter} + '%'
333
333
334
-
{C/* Create the marker table. This table is exists to give others a count of the number of waiting/holding processes.
334
+
{C/* Create the marker table. This table exists to give others a count of the number of waiting/holding processes.
335
335
we name our marker table using the form ##[sem name][spid][separator][value]. We use SPID over a random value since SPID values are typically small integers
336
336
that recycle over time; this means that we may be able to take advantage of SQL temp table caching. The reason we need SPID here at all is because if another
337
337
transaction creates and destroys a table of name X, we will be blocked if we try to create table X before the transaction ends. */}
@@ -443,11 +443,11 @@ IF APPLOCK_MODE('public', @{TicketLockNameParameter}, @{LockScopeVariable}) = 'N
443
443
AND (@{LockScopeVariable} = 'Session' OR APPLOCK_MODE('public', @{TicketLockNameParameter}, 'Session') = 'NoLock')
444
444
BEGIN
445
445
{C/* "allowOneWait" will be specified when we are in a busy wait loop. To avoid burning CPU we pick the first unheld ticket we come
446
-
across and allow that wait to be 32ms instead of 0. This is preferable to doing WAITFOR since the wait will be broken if that ticket
446
+
across and allow that wait to be > 0. This is preferable to doing WAITFOR since the wait will be broken if that ticket
447
447
becomes available. Note that we used to wait just 1ms here. However, in testing that proved flaky in detecting
448
-
deadlocks; empirically, 32ms seems to be sufficient to work reliably. The longer wait should also reduce the
448
+
deadlocks; empirically, 64ms seems to be sufficient to work reliably. The longer wait should also reduce the
449
449
CPU load without meaningfully adding delay overhead (SQL_SEMAPHORE_ONE_WAIT) */}
450
-
{(allowOneWait?"DECLARE @lockTimeoutMillis INT = CASE @anyNotHeld WHEN 0 THEN 32 ELSE 0 END":null)}
450
+
{(allowOneWait?"DECLARE @lockTimeoutMillis INT = CASE @anyNotHeld WHEN 0 THEN 64 ELSE 0 END":null)}
451
451
SET @anyNotHeld = 1
452
452
453
453
{(
@@ -458,7 +458,7 @@ CPU load without meaningfully adding delay overhead (SQL_SEMAPHORE_ONE_WAIT) */}
0 commit comments