Skip to content

Commit 3da3eaf

Browse files
authored
Merge pull request #274 from madelson/release-2.8.1
Release 2.8.1
2 parents 3460336 + 707a04c commit 3da3eaf

11 files changed

Lines changed: 1847 additions & 2069 deletions

File tree

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,10 @@ Setup steps for working with the repository locally are documented [here](docs/D
142142

143143
## Release notes
144144

145+
- 2.8.1
146+
- Fix connection monitoring query on Oracle. Thanks [@matthew-marston](https://github.com/matthew-marston) for implementing! ([#271](https://github.com/madelson/DistributedLock/issues/271), DistributedLock.Oracle 1.0.5)
147+
- Bump Microsoft.Data.SqlClient version ([#273](https://github.com/madelson/DistributedLock/issues/273), DistributedLock.SqlServer 1.0.7)
148+
- Improve `SqlDistributedSemaphore` deadlock detection ([#264](https://github.com/madelson/DistributedLock/issues/264), DistributedLock.SqlServer 1.0.7)
145149
- 2.8.0
146150
- Add MongoDB support! Thanks [@joesdu](https://github.com/joesdu) for implementing! ([#121](https://github.com/madelson/DistributedLock/issues/121), DistributedLock.MongoDB 1.0)
147151
- Add composite lock support. Thanks [@moeen](https://github.com/moeen) for implementing! ([#236](https://github.com/madelson/DistributedLock/issues/236), DistributedLock.Core 1.0.9)

src/Directory.Packages.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<PackageVersion Include="Oracle.ManagedDataAccess" Version="23.6.1" Condition="'$(TargetFramework)' == 'net472'" />
1616
<PackageVersion Include="Npgsql" Version="8.0.6" />
1717
<PackageVersion Include="StackExchange.Redis" Version="2.7.33" />
18-
<PackageVersion Include="Microsoft.Data.SqlClient" Version="5.2.2" />
18+
<PackageVersion Include="Microsoft.Data.SqlClient" Version="6.1.4" />
1919
<PackageVersion Include="nunit" Version="3.14.0" />
2020
<PackageVersion Include="nunit3testadapter" Version="4.5.0" />
2121
<PackageVersion Include="Microsoft.NET.Test.SDK" Version="17.9.0" />

src/DistributedLock.Oracle/DistributedLock.Oracle.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<PropertyGroup>
14-
<Version>1.0.4</Version>
14+
<Version>1.0.5</Version>
1515
<AssemblyVersion>1.0.0.0</AssemblyVersion>
1616
<Authors>Michael Adelson</Authors>
1717
<Description>Provides a distributed lock implementation based on Oracle Database</Description>

src/DistributedLock.Oracle/OracleDatabaseConnection.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,15 @@ private OracleDatabaseConnection(IDbConnection connection, bool isExternallyOwne
3636
// from https://docs.oracle.com/html/E10927_01/OracleCommandClass.htm "this method is a no-op" wrt "Prepare()"
3737
public override bool ShouldPrepareCommands => false;
3838

39-
public override bool IsCommandCancellationException(Exception exception) =>
39+
public override bool IsCommandCancellationException(Exception exception) =>
4040
exception is OracleException oracleException
4141
// based on https://docs.oracle.com/cd/E85694_01/ODPNT/CommandCancel.htm
4242
&& (oracleException.Number == 01013 || oracleException.Number == 00936 || oracleException.Number == 00604);
4343

4444
public override async Task SleepAsync(TimeSpan sleepTime, CancellationToken cancellationToken, Func<DatabaseCommand, CancellationToken, ValueTask<int>> executor)
4545
{
4646
using var sleepCommand = this.CreateCommand();
47-
sleepCommand.SetCommandText("BEGIN sys.DBMS_SESSION.SLEEP(:seconds) END;");
47+
sleepCommand.SetCommandText("BEGIN sys.DBMS_SESSION.SLEEP(:seconds); END;");
4848
sleepCommand.AddParameter("seconds", sleepTime.TotalSeconds);
4949

5050
try

src/DistributedLock.SqlServer/DistributedLock.SqlServer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
</PropertyGroup>
1212

1313
<PropertyGroup>
14-
<Version>1.0.6</Version>
14+
<Version>1.0.7</Version>
1515
<AssemblyVersion>1.0.0.0</AssemblyVersion>
1616
<Authors>Michael Adelson</Authors>
1717
<Description>Provides a distributed lock implementation based on SQL Server</Description>

src/DistributedLock.SqlServer/SqlSemaphore.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ FROM tempdb.sys.tables WITH(NOLOCK)
331331
{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 */}
332332
WHERE name LIKE '##' + @{SemaphoreNameParameter} + '%'
333333
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.
335335
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
336336
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
337337
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
443443
AND (@{LockScopeVariable} = 'Session' OR APPLOCK_MODE('public', @{TicketLockNameParameter}, 'Session') = 'NoLock')
444444
BEGIN
445445
{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
447447
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
449449
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)}
451451
SET @anyNotHeld = 1
452452
453453
{(
@@ -458,7 +458,7 @@ CPU load without meaningfully adding delay overhead (SQL_SEMAPHORE_ONE_WAIT) */}
458458
DECLARE @createIntentMarkerTableSql NVARCHAR(MAX) = 'CREATE TABLE ' + @intentMarkerTableName + ' (_ BIT)'
459459
EXEC sp_executeSql @createIntentMarkerTableSql"
460460
: null
461-
)}
461+
)}
462462
463463
EXEC @{LockResultVariable} = sys.sp_getapplock @{TicketLockNameParameter}, 'Exclusive', @{LockScopeVariable}, {(allowOneWait ? "@lockTimeoutMillis" : "0")}
464464
IF @{LockResultVariable} >= 0
@@ -473,7 +473,7 @@ GOTO CODA
473473
? $@"DECLARE @dropIntentMarkerTableSql NVARCHAR(MAX) = 'DROP TABLE ' + @intentMarkerTableName
474474
EXEC sp_executeSql @dropIntentMarkerTableSql"
475475
: null
476-
)}
476+
)}
477477
478478
{C/* on any unexpected lock failure, quit */}
479479
IF @{LockResultVariable} < -1 GOTO CODA

0 commit comments

Comments
 (0)