我有一个奇怪的问题.我有一个.NET程序,我的进程逻辑在sql Server 2005数据库上需要一个长时间运行的事务(〜20分钟).没关系,因为没有人并行访问数据库.当出现问题时,应该回滚事务.
不频繁且没有任何可见的模式,我的DbTransaction对象上的Rollback()操作会引发sqlException:
Message: "Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding." StackTrace: at System.Data.sqlClient.sqlInternalConnection.OnError(sqlException exception,Boolean breakConnection) at System.Data.sqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj) at System.Data.sqlClient.TdsParserStateObject.ReadSniError(TdsParserStateObject stateObj,UInt32 error) at System.Data.sqlClient.TdsParserStateObject.ReadSni(DbAsyncResult asyncResult,TdsParserStateObject stateObj) at System.Data.sqlClient.TdsParserStateObject.ReadPacket(Int32 bytesExpected) at System.Data.sqlClient.TdsParserStateObject.ReadBuffer() at System.Data.sqlClient.TdsParserStateObject.ReadByte() at System.Data.sqlClient.TdsParser.Run(RunBehavior runBehavior,sqlCommand cmdHandler,sqlDataReader dataStream,BulkCopySimpleResultSet bulkCopyHandler,TdsParserStateObject stateObj) at System.Data.sqlClient.TdsParser.TdsExecuteTransactionManagerRequest(Byte[] buffer,TransactionManagerRequestType request,String transactionName,TransactionManagerIsolationLevel isoLevel,Int32 timeout,sqlInternalTransaction transaction,TdsParserStateObject stateObj,Boolean isDelegateControlRequest) at System.Data.sqlClient.sqlInternalConnectionTds.ExecuteTransactionYukon(TransactionRequest transactionRequest,IsolationLevel iso,sqlInternalTransaction internalTransaction,Boolean isDelegateControlRequest) at System.Data.sqlClient.sqlInternalConnectionTds.ExecuteTransaction(TransactionRequest transactionRequest,String name,Boolean isDelegateControlRequest) at System.Data.sqlClient.sqlInternalTransaction.Rollback() at System.Data.sqlClient.sqlTransaction.Rollback()
我不知道这是否真的是一个超时问题,因为这个代码有时候有时候不工作.此外,我知道的唯一超时是ConnectionTimeout和CommandTimeout,但显然这些不是这种情况下的问题.
有没有人有这个问题的想法?
非常感谢Matthias