ThreadAbortException 调用 OdbcDataReader.ExecuteReader()
我正在使用 OdbcDataReader 类和 ExecuteReader() 方法对大型机 DB2 数据库运行 SQL 查询。 该代码已投入生产并已运行良好数月。
查询通常需要 1-2 分钟来执行。 上周五,查询遇到了 ThreadAbortException。 下面是格式化的堆栈跟踪。 跟踪中的 ApplicationException 是在我的 catch 块中创建的。
如果它很重要,则当客户端调用 Web 服务方法时运行查询。 Web 服务托管在 Windows 服务中。 Web 服务使用soap.tcp 协议托管在Windows 服务中。
有什么想法为什么会发生 TreadAbortException 吗?
2 个异常的堆栈跟踪。 根 原因在顶部。
异常 2:线程被中止。
System.Threading.ThreadAbortException 里面 C:\ WINDOWS \ assembly \ GAC_64 \ System.Data \ 2.0.0.0__b77a5c561934e089 \ System.Data.dll 在 System.Data.Common.UnsafeNativeMethods.SQLExecDirectW(OdbcStatementHandle 语句句柄、字符串语句文本、 Int32 TextLength)位于 System.Data.Odbc.OdbcStatementHandle.ExecuteDirect(字符串 命令文本)位于 System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为、字符串方法、布尔值 needReader, Object[] 方法参数, SQL_API odbcApiMethod) 位于 System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为、字符串方法、布尔值 需要阅读器)在 System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior 行为)在 MyCompany.MyDatabase.GetFolioList(字符串 sqlWhereClause)异常 1:无法检索作品集 摘要列表,其中 STAT_CD='V'。
System.ApplicationException 内部 D:\Production\DBGateway\bin\MyDatabase.dll 在 MyCompany.MyDatabase.GetFolioList(字符串 sqlWhereClause) 在 MyCompany.MyDatabase.<>c__DisplayClass18.b__17() 在 MyCompany.WebUtilities.WebServiceBase.WebMethodTemplate[T](字符串 方法名称,字符串异常格式, WebMethodWorker1 个工作人员, StringFormatter
1 FormatterMethod)
I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class and ExecuteReader() method. This code is in production and has been running fine for months.
The query normally takes 1-2 minutes to execute. This past Friday, the query encountered a ThreadAbortException. Below is the formatted stack trace. The ApplicationException in the trace is created in my catch block.
In case it is important, the query is run when a client calls a web service method. The web service is hosted in a Windows Service. The web service is hosted in a Windows Service using the soap.tcp protocol.
Any ideas why the TreadAbortException is happening?
Stack trace for 2 exception(s). Root
cause at the top.Exception 2: Thread was being aborted.
System.Threading.ThreadAbortException
inside
C:\WINDOWS\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll
at
System.Data.Common.UnsafeNativeMethods.SQLExecDirectW(OdbcStatementHandle
StatementHandle, String StatementText,
Int32 TextLength) at
System.Data.Odbc.OdbcStatementHandle.ExecuteDirect(String
commandText) at
System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior
behavior, String method, Boolean
needReader, Object[] methodArguments,
SQL_API odbcApiMethod) at
System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior
behavior, String method, Boolean
needReader) at
System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior
behavior) at
MyCompany.MyDatabase.GetFolioList(String
sqlWhereClause)Exception 1: Unable to retrieve the folio
summary list where STAT_CD='V'.
System.ApplicationException inside
D:\Production\DBGateway\bin\MyDatabase.dll
at
MyCompany.MyDatabase.GetFolioList(String
sqlWhereClause) at
MyCompany.MyDatabase.<>c__DisplayClass18.b__17()
at
MyCompany.WebUtilities.WebServiceBase.WebMethodTemplate[T](String
methodName, String exceptionFormat,
WebMethodWorker1 Worker,
1 FormatterMethod)
StringFormatter
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这是我自己的问题的答案。
托管 Web 服务时,有一些进程会监视 Web 服务调用所花费的时间。 如果调用花费的时间太长,则会终止该调用并出现 ThreadAbortException。 可以增加超时时间。
对于在 ASP.NET 外部运行的 WSE3 Web 服务,例如托管为soap.tcp(如我的),配置属性为executionTimeoutInSeconds:
对于托管在 ASP.NET 中的 Web 服务,配置属性为executionTimeout:
Here is the answer to my own question.
When hosting a web service, there is some process monitoring how long a web service call is taking. If a call is taking too long, then it is killed and a ThreadAbortException will occur. The timeout can be increased.
For a WSE3 web service running outside of ASP.NET, e.g. hosted as soap.tcp (like mine), the configuration property is executionTimeoutInSeconds:
For a web service hosted in ASP.NET, the configuration property is executionTimeout:
您的线程可能被选为乐观锁定导致的死锁情况的受害者,尽管在这种情况下我希望负责层来处理它。
ThreadAbortExceptions 可能由多种原因引起,包括其他应用程序或 CLR 主机中止线程。 您的代码是否由另一个应用程序托管? (开创性的例子是 Sql Server,尽管您的情况似乎并非如此。)
It might be possible that your thread was chosen as the victim in a deadlock situation resulting from optimistic locking, though in that case I would have expected the responsible layer to handle it.
ThreadAbortExceptions can be caused by many things, including other applications or the CLR host aborting the thread. Is your code being hosted by another application? (The seminal example would be Sql Server, though that doesn't appear to be the situation in your case.)