System.Data.SqlClient.SqlException(0x80131904):执行超时过期,错误号:-2

时间:2019-05-16 14:17:05

标签: c# .net sql-server sqlclient

我有一个连接到SQL Server 2014的C#.NET 4.7.2应用程序。从该应用程序调用的存储过程之一遇到以下错误:

xyzStoredProcedure: Exception encountered. System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out
at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString, Boolean isInternal, Boolean forDescribeParameterEncryption, Boolean shouldCacheForAlwaysEncrypted)
at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, Boolean inRetry, SqlDataReader ds, Boolean describeParameterEncryptionRequest)
at System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.InternalExecuteNonQuery(TaskCompletionSource`1 completion, String methodName, Boolean sendToPipe, Int32 timeout, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry)
at System.Data.SqlClient.SqlCommand.ExecuteNonQuery()
at Application.SomeMethod()
ClientConnectionId: {f0b2bed5-8baf-444a-b969-500ac2ca3aad}
Error Number:-2,State:0,Class:11

我了解Execution Timeout Expired意味着应用程序能够与数据库建立连接,并且数据库开始运行存储过程,但是存储过程的运行时间超过了应用程序中设置的超时值,因此应用程序放弃了在存储过程上。

但是,MSDN描述了Error Number:-2,如图所示,显示在异常堆栈的末尾。

enter image description here 图像中的Message TextExplanation和异常堆栈中的Execution Timeout Expired似乎彼此不一致。

问题:

  1. MSDN是否不正确?

  2. 有人可以解释由Execution Timeout Expired导致Error Number: -2的原因吗?来自相同应用程序进程,相同连接字符串,相同数据库以及该错误的大约相同时间的其他存储过程都可以正常工作。

  3. StateClass Number在异常堆栈中代表什么?

0 个答案:

没有答案