1

我的事务范围经常中止

我背后的问题:

当使用不同的类打开多个事务范围时,我们面临事务中止的错误,每个类都嵌套并且在方法中事务范围被初始化,但是没有调用声明事务范围的方法,而是给出超时和事务范围反复中止。

我的堆栈跟踪如下:

System.Transactions.TransactionAbortedException 被捕获
HResult=-2146233087 Message=事务已中止。
源 = System.Transactions

StackTrace:
       at System.Transactions.TransactionStatePromotedAborted.CreateAbortingClone(InternalTransaction tx)
       at System.Transactions.DependentTransaction..ctor(IsolationLevel isoLevel, InternalTransaction internalTransaction, Boolean blocking)
       at System.Transactions.Transaction.DependentClone(DependentCloneOption cloneOption)
       at System.Transactions.TransactionScope.SetCurrent(Transaction newCurrent)
       at System.Transactions.TransactionScope..ctor(TransactionScopeOption scopeOption)
       at TrapError.ErrorDescription..ctor()
       at QueryRecordsets.FetchRecordsets..ctor()
  InnerException: System.TimeoutException
       HResult=-2146233083
       Message=Transaction Timeout
       InnerException:   

在分析错误描述时,它具有以下信息:

Event code: 3005 
Event message: An unhandled exception has occurred. 
Event time: 10/30/2013 9:19:31 AM 
Event time (UTC): 10/30/2013 3:49:31 AM 
Event ID: 057d425ae7424adbb9a021d856f0d3e0 
Event sequence: 14 
Event occurrence: 1 
Event detail code: 0 

Application information: 
    Application domain: /LM/W3SVC/1/ROOT/eSmartDotNet-2-130275784247371995 
    Trust level: Full 
    Application Virtual Path: /eSmartDotNet 
    Application Path: I:\Rafiq\29-10-2013\Source Code Esmart Application\ 
    Machine name: WINSERVER2012 

Process information: 
    Process ID: 4908 
    Process name: w3wp.exe 
    Account name: IIS APPPOOL\DefaultAppPool 

Exception information: 
    Exception type: HttpUnhandledException 
    Exception message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
   at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

The transaction has aborted.
   at QueryRecordsets.FetchRecordsets..ctor()
   at ASP.logincheck_aspx.__Render__control1(HtmlTextWriter __w, Control parameterContainer) in I:\Rafiq\29-10-2013\Source Code Esmart Application\LoginCheck.aspx:line 42
   at System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children)
   at System.Web.UI.Page.Render(HtmlTextWriter writer)
   at System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

Transaction Timeout



Request information: 
    Request URL: http://localhost/eSmartDotNet/LoginCheck.aspx 
    Request path: /eSmartDotNet/LoginCheck.aspx 
    User host address: ::1 
    User:  
    Is authenticated: False 
    Authentication Type:  
    Thread account name: IIS APPPOOL\DefaultAppPool 

Thread information: 
    Thread ID: 33 
    Thread account name: IIS APPPOOL\DefaultAppPool 
    Is impersonating: False 
    Stack trace:    at System.Web.UI.Page.HandleError(Exception e)
   at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
   at System.Web.UI.Page.ProcessRequest()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
4

1 回答 1

1

我不确定 TransactionScope 是否可以在 Oracle 上运行。我的直觉是它依赖于 MS 技术,例如 MS 分布式事务协调器 (MSDTC)。这似乎得到了 MSDN 文档中关于System.Transactions 命名空间的证实(我的重点是 MS 技术);

System.Transactions 基础结构通过支持在SQL Server、ADO.NET、MSMQ 和Microsoft 分布式事务协调器 (MSDTC)中启动的事务,使整个平台的事务编程变得简单而高效。它既提供了基于 Transaction 类的显式编程模型,也提供了使用TransactionScope 类的隐式编程模型,其中事务由基础设施自动管理。

还有一堆 SO 帖子似乎表明他们在与 Oracle 合作时也遇到了问题;

将 TransactionScope 与 System.Data.OracleClient 一起使用 - TransactionAbortedException

TransactionScope 和 Oracle 的问题

带有 ASP.NET 的 Oracle 中的事务范围

最后一个链接似乎表明了 Oracle 特定的 DTC,但仍然没有提供太多希望。您可能需要查看除 TransactionScope 之外的其他处理事务的替代方案。

于 2013-10-30T05:48:18.547 回答