runtime
runtime copied to clipboard
Crash in SqlConnection.Close() when using TransactionScope on linux.
I'm using SqlClient 4.5.0-preview1-26207-04 in netcoreapp2.0.
.NET Command Line Tools (2.0.0)
Product Information:
Version: 2.0.0
Commit SHA-1 hash: cdcd1928c9
Runtime Environment:
OS Name: centos
OS Version: 7
OS Platform: Linux
RID: centos.7-x64
Base Path: /usr/share/dotnet/sdk/2.0.0/
Microsoft .NET Core Shared Framework Host
Version : 2.0.0
Build : e8b8861ac7faf042c87a5c2f9f2d04c98b69f28d
The following snippet would crash on the above machine (removed some code for brevity). Works without issues on Windows.
using (var txscope = new TransactionScope(TransactionScopeAsyncFlowOption.Enabled))
using (var cn = _dBProvider.GetWriteConnection())
{
await cn.OpenAsync();
if (cmd.RecordCertificationStatus)
{
await cn.ExecuteAsync(@"INSERT INTO (...) (@iduser, @idtitle, @value, getdate()); ",
new { @iduser = cmd.SubId, @idtitle=cmd.EntityId, @value = cmd.Model.IsCertified });
}
await cn.ExecuteAsync(sql, data);
txscope.Complete();
}
Both statements are inserts. Stacktrace is below:
"System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.ProviderBase.DbConnectionPool.DeactivateObject(DbConnectionInternal obj)
at System.Data.ProviderBase.DbConnectionPool.PutObject(DbConnectionInternal obj, Object owningObject)
at System.Data.ProviderBase.DbConnectionInternal.CloseConnection(DbConnection owningObject, DbConnectionFactory connectionFactory)
at System.Data.SqlClient.SqlConnection.Close()
at System.Data.SqlClient.SqlConnection.Dispose(Boolean disposing)
at System.ComponentModel.Component.Dispose()
at ...TitleUpdate.Handler.<HandleCore>d__2.MoveNext() in ...TitleUpdate.cs:line 189
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at MediatR.Internal.RequestHandlerWrapperImpl`1.<>c__DisplayClass0_0.<<Handle>g__Handler0>d.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at ...ValidationBehavior`2.<Handle>d__2.MoveNext() in ...ValidationBehavior.cs:line 34
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at ....TitlesController.<Update>d__5.MoveNext() in TitleController.cs:line 98
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeActionMethodAsync>d__12.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeNextActionFilterAsync>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Rethrow(ActionExecutedContext context)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted)
at Microsoft.AspNetCore.Mvc.Internal.ControllerActionInvoker.<InvokeInnerFilterAsync>d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.Mvc.Internal.ResourceInvoker.<InvokeNextExceptionFilterAsync>d__23.MoveNext()"
@evgeniylevakhin What is the version of System.Data.SqlClient that you are using?
Sorry I realized you had put it in the issue.
Hi @evgeniylevakhin,
I am looking into this issue, I will get back to you once I have any questions/updates.
Regards, Keerat