4

我正在使用 OdbcDataReader 类和 ExecuteReader() 方法对大型机 DB2 数据库运行 SQL 查询。这段代码正在生产中,几个月来一直运行良好。

查询通常需要 1-2 分钟才能执行。上周五,查询遇到了 ThreadAbortException。下面是格式化的堆栈跟踪。跟踪中的 ApplicationException 是在我的 catch 块中创建的。

如果它很重要,则在客户端调用 Web 服务方法时运行查询。Web 服务托管在 Windows 服务中。Web 服务使用soap.tcp 协议托管在Windows 服务中。

任何想法为什么会发生 TreadAbortException?

2 个异常的堆栈跟踪。根本原因在顶部。

异常 2:线程被中止。
System.Threading.ThreadAbortException inside C:\WINDOWS\assembly\GAC_64\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll 在 System.Data.Common.UnsafeNativeMethods.SQLExecDirectW(OdbcStatementHandle StatementHandle, String StatementText, Int32 TextLength) 在System.Data.Odbc.OdbcStatementHandle.ExecuteDirect(String commandText) 在 System.Data.Odbc.OdbcCommand.ExecuteReaderObject(CommandBehavior 行为,String 方法,布尔需要Reader,Object[] methodArguments,SQL_API odbcApiMethod) 在 System.Data.Odbc.OdbcCommand。 MyCompany.MyDatabase.GetFolioList(String sqlWhereClause) 中 System.Data.Odbc.OdbcCommand.ExecuteReader(CommandBehavior 行为) 中的 ExecuteReaderObject(CommandBehavior 行为,String 方法,Boolean needReader)

例外 1:无法检索 STAT_CD='V' 的作品集摘要列表。
System.ApplicationException 在 D:\Production\DBGateway\bin\MyDatabase.dll 在 MyCompany.MyDatabase.GetFolioList(String sqlWhereClause) 在 MyCompany.MyDatabase.<>c__DisplayClass18.b__17() 在 MyCompany.WebUtilities.WebServiceBase.WebMethodTemplate[T]( String methodName, String exceptionFormat, WebMethodWorker 1 Worker, StringFormatter1 FormatterMethod)

4

2 回答 2

4

这是我自己的问题的答案。

托管 Web 服务时,有一些进程监控 Web 服务调用所用的时间。如果一个调用花费的时间太长,那么它会被终止并且会发生 ThreadAbortException。超时时间可以增加。

对于在 ASP.NET 之外运行的 WSE3 Web 服务,例如托管为 soap.tcp(就像我的一样),配置属性是 executionTimeoutInSeconds:

<configuration>
  <microsoft.web.services3>
    <messaging>
      <executionTimeoutInSeconds value="360" />
    </messaging>
  </microsoft.web.services3>
</configuration>

对于托管在 ASP.NET 中的 Web 服务,配置属性是 executionTimeout:

<configuration>
<system.web>
            <httpRuntime executionTimeout=”360” />
      </system.web>
</configuration
于 2009-01-07T21:32:44.870 回答
0

在乐观锁定导致的死锁情况下,您的线程可能被选为受害者,但在这种情况下,我希望负责层来处理它。

ThreadAbortExceptions 可能由许多原因引起,包括其他应用程序或 CLR 主机中止线程。您的代码是否由另一个应用程序托管?(开创性的例子是 Sql Server,尽管在您的情况下似乎不是这种情况。)

于 2008-11-17T20:45:04.193 回答