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
While attempting to write to a table using a table valued parameters with MARS on I am getting a NullReferenceException and the following stack trace.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags)
at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose()
at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose()
at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session)
at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult)
at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction,
Since upgrading to 2.1 I've started getting this, also using TVPs, via ExecuteSqlCommand to do inserts and updates. I've noticed it when our system is under fairly large load e.g. when making 20 of these calls at the same time, and a successful call takes 20 secs (updates a lot of records in one hit), and often the other calls are either also throwing this NullReferenceException or else they're throwing timeout.
So I guess this happens when you're recovering from another exception by unwinding the stack, and disposing something that isn't in an expected state?
Stack trace comes at the problem from a slightly different route:
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags)
at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose()
at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose()
at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteNonQuery(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlCommand(DatabaseFacade databaseFacade, RawSqlString sql, IEnumerable`1 parameters)
I have hit the same issue with 2.2.101 running on ubuntu (WSL). I will try and put together a simple repro and report back.
Error Message:
System.NullReferenceException : Object reference not set to an instance of an object.
Stack Trace:
at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet)
at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags)
at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose()
at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose()
at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session)
at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
I have also hit the same issue.
Don't have much to add tho.
I'm running dotnetcore 2.1.5
System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags) at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose() at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose() at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session) at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)
It frequently reporducalbe with MARS enabled and high rate of concurrent queris.
We are using latest images from microsoft/dotnet:2.2-runtime-deps-alpine
and microsoft/dotnet:2.1-runtime-deps-alpine
We are runing them on CentOS, and trying to conntect to AWS RDS instance, if it somehow helpful.
Object reference not set to an instance of an object.
at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags) at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose() at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose() at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
@iwanttodie@Spaceman1861@zentron if the issue is occurring often, do you think you can manage to provide a repro? This would help us with investigating the issue :) Thanks!
If you can provide a reproduction i can investigate and probably fix this issue. Without a reproduction all i have to rely on is guesswork and that isn't an effective or efficient use of time so we may as well close the issue.
System.NullReferenceException: Object reference not set to an instance of an object.
at System.Data.SqlClient.SNI.SNIPacket.ReadFromStreamAsync(Stream stream, SNIAsyncCallback callback)
at System.Data.SqlClient.SNI.SNITCPHandle.ReceiveAsync(SNIPacket& packet)
at System.Data.SqlClient.SNI.SNIMarsConnection.ReceiveAsync(SNIPacket& packet)
at System.Data.SqlClient.SNI.SNIMarsConnection.HandleReceiveComplete(SNIPacket packet, UInt32 sniErrorCode)
at System.Data.SqlClient.SNI.SNIPacket.<ReadFromStreamAsync>g__ReadFromStreamAsync|27_0(SNIPacket packet, SNIAsyncCallback cb, ValueTask`1 valueTask)
I seem to be able to repro it quite easily, but that is running our application, it will be quite difficult to repro it in isolation.
@yukiwongky, as I said, trying to create a small repro, is quite difficult for us. We have tried before but weren't able.
However, we can offer you a pod in our Kubernetes Cluster that we can repro this issue in?
Closing this issue as no repro code is available and no new additional customers have reported this issue.
Would recommend testing with Microsoft.Data.SqlClient latest versions (as significant changes are made to this driver in recent times) and open a new issue with repro application if reproduced.
Activity
saurabh500 commentedon Feb 20, 2018
@domisterwoozy What is the version of SqlClient that you are using?
Can you post a repro application?
AfsanehR-zz commentedon Feb 22, 2018
Hello @domisterwoozy. I wasn't able to repro the issue. Please see the attached file for a sample application that I ran with tvp and MARS enabled.
https://gist.github.com/AfsanehR/a841749664520918035f6f42c5869351
If you can post a repro, it would be useful to better investigate the issue you are facing.
saurabh500 commentedon Feb 26, 2018
Moving to Future as there is not enough actionable information available. @domisterwoozy a repro would really help us tackle the issue.
danielearwicker commentedon Jun 29, 2018
Since upgrading to 2.1 I've started getting this, also using TVPs, via
ExecuteSqlCommandto do inserts and updates. I've noticed it when our system is under fairly large load e.g. when making 20 of these calls at the same time, and a successful call takes 20 secs (updates a lot of records in one hit), and often the other calls are either also throwing thisNullReferenceExceptionor else they're throwing timeout.So I guess this happens when you're recovering from another exception by unwinding the stack, and disposing something that isn't in an expected state?
Stack trace comes at the problem from a slightly different route:
AfsanehR-zz commentedon Jun 29, 2018
Do you also have the MARS ON in your setting? Would you be able to give us a repro, that would help us track down issue easier.
zentron commentedon Feb 5, 2019
I have hit the same issue with
2.2.101running on ubuntu (WSL). I will try and put together a simple repro and report back.Spaceman1861 commentedon Feb 8, 2019
I have also hit the same issue.
Don't have much to add tho.
I'm running dotnetcore 2.1.5
System.NullReferenceException: Object reference not set to an instance of an object. at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags) at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose() at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose() at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session) at System.Data.SqlClient.SqlCommand.EndExecuteNonQuery(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncCoreLogic(IAsyncResult iar, Func2 endFunction, Action1 endAction, Task1 promise, Boolean requiresSynchronization)sdiakovskyi-gd commentedon Apr 12, 2019
It frequently reporducalbe with MARS enabled and high rate of concurrent queris.
We are using latest images from
microsoft/dotnet:2.2-runtime-deps-alpineand
microsoft/dotnet:2.1-runtime-deps-alpineWe are runing them on CentOS, and trying to conntect to AWS RDS instance, if it somehow helpful.
Object reference not set to an instance of an object.
at System.Data.SqlClient.SNI.SNITCPHandle.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsConnection.Send(SNIPacket packet) at System.Data.SqlClient.SNI.SNIMarsHandle.SendControlPacket(SNISMUXFlags flags) at System.Data.SqlClient.SNI.SNIMarsHandle.Dispose() at System.Data.SqlClient.SNI.TdsParserStateObjectManaged.Dispose() at System.Data.SqlClient.TdsParserSessionPool.PutSession(TdsParserStateObject session) at System.Data.SqlClient.SqlCommand.RunExecuteNonQueryTds(String methodName, Boolean async, Int32 timeout, Boolean asyncWrite) at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, Boolean sendToPipe, Int32 timeout, Boolean asyncWrite, String methodName) at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
AfsanehR-zz commentedon Apr 12, 2019
@iwanttodie @Spaceman1861 @zentron if the issue is occurring often, do you think you can manage to provide a repro? This would help us with investigating the issue :) Thanks!
divega commentedon May 16, 2019
As recently announced in the .NET Blog, focus on new SqlClient features an improvements is moving to the new Microsoft.Data.SqlClient package. For this reason, we are moving this issue to the new repo at https://github.com/dotnet/SqlClient. We will still use https://github.com/dotnet/corefx to track issues on other providers like System.Data.Odbc and System.Data.OleDB, and general ADO.NET and .NET data access issues.
Wraith2 commentedon May 22, 2019
If you can provide a reproduction i can investigate and probably fix this issue. Without a reproduction all i have to rely on is guesswork and that isn't an effective or efficient use of time so we may as well close the issue.
cheenamalhotra commentedon Oct 8, 2019
@domisterwoozy
Please let us know if you're still facing this issue and provide more info on the use case, so we can reproduce at our end.
johnsimons commentedon Nov 7, 2019
I am getting a very similar issue in netcoreapp 2.2 running on docker based on http://mcr.microsoft.com/dotnet/core/sdk:2.2 image
With https://www.nuget.org/packages/System.Data.SqlClient/4.7.0
I seem to be able to repro it quite easily, but that is running our application, it will be quite difficult to repro it in isolation.
yukiwongky commentedon Nov 7, 2019
@johnsimons would be great if you can provide us with a repro script. Do you also encounter this error when trying to use TVP?
johnsimons commentedon Nov 8, 2019
@yukiwongky, as I said, trying to create a small repro, is quite difficult for us. We have tried before but weren't able.
However, we can offer you a pod in our Kubernetes Cluster that we can repro this issue in?
cheenamalhotra commentedon Nov 3, 2020
Closing this issue as no repro code is available and no new additional customers have reported this issue.
Would recommend testing with Microsoft.Data.SqlClient latest versions (as significant changes are made to this driver in recent times) and open a new issue with repro application if reproduced.