-
Notifications
You must be signed in to change notification settings - Fork 240
Open
Description
We use the Sql Server implemention of DistributedLock, currently DistributedLock.SqlServer 1.0.5.
I have seen that sometimes we have exceptions when calling DisposeAsync(). In general I thought Dispose/DisposeAsync shouldn't throw, but Im not sure in this case? Is it a bug, or something I should expect?
Our usage is something like this
var cnx = await GetOpenConnection(connectionStringName);
var @lock = new SqlDistributedLock(lockName, cnx);
await using var handle = await @lock.TryAcquireAsync(expiryTime, cancellationToken);
... logic hereThen sometimes there's an exception on Dispose, with this stacktrace:
Microsoft.Data.SqlClient.SqlException (0x80131904): A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 2 - Connection was terminated)
at Microsoft.Data.SqlClient.SqlCommand.EndExecuteNonQueryAsync(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location ---
at Medallion.Threading.Internal.Data.DatabaseCommand.ExecuteAsync[TResult](Func`3 executeAsync, Func`2 executeSync, CancellationToken cancellationToken, Boolean disallowAsyncCancellation, Boolean isConnectionMonitoringQuery) in /_/src/DistributedLock.Core/Internal/Data/DatabaseCommand.cs:line 82
at Medallion.Threading.SqlServer.SqlApplicationLock.ExecuteReleaseCommandAsync(DatabaseConnection connection, String lockName, Boolean isTry) in /_/src/DistributedLock.SqlServer/SqlApplicationLock.cs:line 67
at Medallion.Threading.Internal.Data.DedicatedConnectionOrTransactionDbDistributedLock.Handle`1.InnerHandle.DisposeAsync() in /_/src/DistributedLock.Core/Internal/Data/DedicatedConnectionOrTransactionDbDistributedLock.cs:line 222
at Medallion.Threading.Internal.Data.DedicatedConnectionOrTransactionDbDistributedLock.Handle`1.InnerHandle.DisposeAsync() in /_/src/DistributedLock.Core/Internal/Data/DedicatedConnectionOrTransactionDbDistributedLock.cs:line 227
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels