所以我们有一个运行的进程,它调用我们的数据库来获取一些数据。当我们运行通过 SQL Server Management Studio 调用的 proc 时,运行时间从 6 分钟到 15 分钟不等,但确实完成了。当我们通过代码运行它时,它总是超时。我的猜测是超出了代码的预期超时范围,但如果可以,proc 实际上仍会运行,因为它直接通过 Management Studio 界面运行。
以下是异常详细信息:
InnerException: System.Data.SqlClient.SqlException
Message=Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding.
Source=.Net SqlClient Data Provider
ErrorCode=-2146232060
Class=11
LineNumber=0
Number=-2
Procedure=""
Server=KSQCOREDBINT
State=0
如果它有帮助,这里是堆栈跟踪:
StackTrace:
at System.Data.SqlClient.SqlConnection.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.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at Chatham.Panda.DataAccessLayer.CoreDataContext.sp_calc_schedule_rates_retrieve(Nullable`1 se_sched_id) in c:\TeamCity\BuildAgent02\work\36e300184c20475\Chatham.Panda.DataAccessLayer\Core.designer.cs:line 2306
at Chatham.Panda.EndOfDay.EodDataAccess.<>c__DisplayClass15.<SpCalcScheduleRatesRetrieve>b__14(CoreDataManager coreDataManager) in C:\svn\K2\trunk\panda\ScheduleBuilderService\Chatham.Panda.EndOfDay\EodDataAccess.cs:line 134
at Chatham.Panda.EndOfDay.EodDataAccess.RunStoredProc[T](Func`2 storedProcDelegate, String storedProcName) in C:\svn\K2\trunk\panda\ScheduleBuilderService\Chatham.Panda.EndOfDay\EodDataAccess.cs:line 21
无论如何,我们可以增加分配的超时范围还是什么?我们一直在努力改进存储过程,但这取决于数据库团队。只是想看看我能不能做点什么。
谢谢。