I've got a stored procedure that is giving me a SqlException because of a timeout when I run it from code (with timeout set to 30).
When I run the procedure directly in Management Studio, it executes in under 1 second.
I also only get the timeout when running it against a specific database.
When I use other databases it finishes quickly without an error.
Here is the full error message:
System.Data.SqlClient.SqlException (0x80131904): Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning()
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
at System.Data.SqlClient.SqlDataReader.ConsumeMetaData()
at System.Data.SqlClient.SqlDataReader.get_MetaData()
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, DbAsyncResult result)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method)
at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method)
at System.Data.SqlClient.SqlCommand.ExecuteDbDataReader(CommandBehavior behavior)
at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader(CommandBehavior behavior)
Does this stack trace mean anything to anyone? It looks like maybe my sproc completed and it timed out while trying to read some kind of meta data?
I tried looking at the process while it is running and it is Suspended. sys.dm_os_waiting_tasks shows the wait type as IO_COMPLETION, if that's of any use. The only processes I see on the database using sp_who2 'active' are the one timing out and my active SSMS window so I don't think it's a blocking issue. I verified this database has the same indeces as a working database and ran dbcc checkdb without any errors on it. How can I determine the cause of the timeout?
ARITHABORT
setting but it really could be any of theSET
options causing a different plan. – Offend