我有2個在Sql Server數據庫中讀取和生成數據的作業。每過一段時間,作業都會與System.Transactions.TransactionInDoubtException一起崩潰。確切的堆棧跟蹤是:System.Transactions.TransactionInDoubtException的原因
Unhandled Exception: System.Transactions.TransactionInDoubtException: The transaction is in doubt. ---> System.Data.SqlClient.SqlException: Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception: The wait operation timed out. Exitcode: -532462766
--- End of inner exception stack trace ---
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
at System.Data.SqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj, UInt32 error)
at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
at System.Data.SqlClient.TdsParserStateObject.TryReadNetworkPacket()
at System.Data.SqlClient.TdsParserStateObject.TryPrepareBuffer()
at System.Data.SqlClient.TdsParserStateObject.ReadSniSyncOverAsync()
at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
at System.Data.SqlClient.TdsParserStateObject.TryReadByte(Byte& value)
at System.Data.SqlClient.TdsParser.Run(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj)
我用Google搜索了一下這件事,發現一些有關MSDTC,但我覺得這不可能是問題,因爲該交易應該是當地的,因爲工作只是一個單一的數據庫上運行。下面的查詢:
SELECT cntr_value AS NumOfDeadLocks
FROM sys.dm_os_performance_counters
WHERE object_name = 'SQLServer:Locks'
AND counter_name = 'Number of Deadlocks/sec'
AND instance_name = '_Total'
顯示,已經有數據庫中無死鎖,所以死鎖不能成爲理由。我在互聯網上找不到任何其他資源,它提供了有關例外原因的確切信息。那麼有沒有人知道原因可能是什麼,或者如何找到這個錯誤的根源?
感謝您的回覆。事實上,錯誤已經不再發生,所以我認爲這是一個鎖定的資源造成的異常重負載導致超時,並把交易就像你已經解釋過的那樣。無論如何,你的回覆讓我更加了解原因可能是什麼。感謝那。 –