2013-10-30 48 views
1

我的交易範圍都退出往往事務範圍被中止經常

我背後的問題:

打開與不同類別的多個事務範圍時

,我們面臨交易中止的錯誤,每個類是嵌套並且在事務範圍初始化的方法中,但是未聲明事務範圍聲明的方法,但是超時和事務範圍被重複中止。

我的堆棧跟蹤如下:

System.Transactions.TransactionAbortedException被抓住
的HResult = -2146233087消息=該交易已中止。
源= 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) 
+0

也許使用SQL Server Profiler來計算正在執行的查詢並查看是否存在任何明顯的問題。一旦你有查詢正在執行,請嘗試在SSMS中運行它,並檢查實際的執行計劃,看看它爲什麼要花這麼長時間。 –

+0

@MrMoose我們正在使用oracle 11g的任何替代方案嗎? –

+0

對不起,我以爲你使用SQL Server是因爲使用了其他MS技術。我不確定它將如何與Oracle合作。請參閱我的回答以瞭解我的想法。然而,我很高興能夠糾正。 –

回答

1

我不知道那的TransactionScope將在甲骨文工作。我的直覺是它依賴於MS分佈式事務協調器(MSDTC)等MS技術。這似乎得到了MSDN文檔System.Transactions namespace的確認(我的重點指出了MS技術);

的System.Transactions的基礎設施使得交易編程 整個平臺的簡單而有效的通過支持SQL服務器,ADO.NET,MSMQ發起 交易,以及微軟 分佈式事務處理協調器(MSDTC) 。它提供基於Transaction類的 顯式編程模型以及使用TransactionScope類的隱式編程模型 ,這些事務由基礎結構自動管理。

還有一堆SO帖子似乎表明他們在使用Oracle時也遇到了問題;

Using TransactionScope with System.Data.OracleClient - TransactionAbortedException

Problems with TransactionScope and Oracle

Transaction Scope in Oracle with ASP.NET

最後一個環節似乎表明一個Oracle特定的DTC,但仍然沒有提供太多的希望。您可能需要查看用於處理除TransactionScope以外的事務的其他選項。