NullReferenceException on timeout instead of SqlException.
I see only couple of them in production for the last month.
ExceptionDetail_HResult -2147467261
ExceptionDetail_Message Object reference not set to an instance of an object.
ExceptionDetail_Source Microsoft.Data.SqlClient
ExceptionDetail_StackTrace
at Microsoft.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at Microsoft.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at Microsoft.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at Microsoft.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at Microsoft.Data.SqlClient.TdsParser.ProcessAttention(TdsParserStateObject stateObj)
at Microsoft.Data.SqlClient.TdsParser.ProcessPendingAck(TdsParserStateObject stateObj)
at Microsoft.Data.SqlClient.TdsParserStateObject.ResetCancelAndProcessAttention()
at Microsoft.Data.SqlClient.TdsParserStateObject.CloseSession()
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 Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.Storage.RelationalCommand.ExecuteNonQueryAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
at Microsoft.EntityFrameworkCore.RelationalDatabaseFacadeExtensions.ExecuteSqlRawAsync(DatabaseFacade databaseFacade, String sql, IEnumerable`1 parameters, CancellationToken cancellationToken)
at ...
ExceptionDetail_TargetSite Void ReadSniSyncOverAsync()
ExceptionDetail_Type System.NullReferenceException
observed_timestamp 1781769665345251900
CommandTimeout '60'
CommandType 'Text',
EventId_Id 20102
EventId_Name Microsoft.EntityFrameworkCore.Database.Command.CommandError
commandText DELETE dbo.SYSException WHERE CreatedOn < @CutoffTime
elapsed 65,002
message_template_text Failed executing DbCommand ({elapsed}ms) [Parameters=[{parameters}], CommandType='{commandType}', CommandTimeout='{commandTimeout}']{newLine}{commandText}
newLine
observed_timestamp 1781769665329176300
parameters @CutoffTime='?' (DbType = DateTime)
scope_name Microsoft.EntityFrameworkCore.Database.Command
Describe the bug
NullReferenceException on timeout instead of SqlException.
I see only couple of them in production for the last month.
Further technical details
Microsoft.Data.SqlClient version: 6.1.2
EF Core: Microsoft.EntityFrameworkCore.SqlServer 9.0.7
.NET target: .Net 9
SQL Server version: SQL Server 2022
Operating system: Windows Server 2022
multipleactiveresultsets=True
Additional context
Similar to #3720