The main question for this publication is "Why should an LTM waterproof transaction never doubt?"
I get a System.Transactions.TransactionInDoubtException and I cannot explain why. Unfortunately, I cannot reproduce this problem, but according to the trace files this happens. I use SQL 2005, connecting to one database and using one SQLConnection, so I do not expect a promotion. An error message indicates a timeout. However, sometimes I get a message with a timeout, but the exception is that the transaction is aborted, and not in doubt that it is much easier to handle.
Here is the full stack trace:
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.
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.ReadNetworkPacket ()
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, String transactionName, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
at System.Data.SqlClient.SqlInternalConnectionTds.ExecuteTransaction (TransactionRequest transactionRequest, String name, IsolationLevel iso, SqlInternalTransaction internalTransaction, Boolean isDelegateControlRequest)
at System.Data.SqlClient.SqlDelegatedTransaction.SinglePhaseCommit (SinglePhaseEnlistment enlistment)
--- End of inner exception stack trace ---
at System.Transactions.TransactionStateInDoubt.EndCommit (InternalTransaction tx)
at System.Transactions.CommittableTransaction.Commit ()
at System.Transactions.TransactionScope.InternalDispose ()
at System.Transactions.TransactionScope.Dispose ()
Any ideas? Why do I get doubt and what should I do when I receive it?
EDIT for more information
. , . , . HEAVILY , , - .
, , . , ? SIngle Phase commit ( strack), , , , , - . , .
, . .
http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=914869&SiteID=1
, , . , .
using (TransactionScope ts = new TransactionScope())
{
transactionCreated = true;
//part of the workarround for microsoft defect mentioned in the beginning of this class
Transaction txClone = Transaction.Current.Clone();
transactions[txClone] = txClone;
Transaction.Current.TransactionCompleted += new TransactionCompletedEventHandler(TransactionCompleted);
MyTrace.WriteLine("Transaction clone stored and attached to event");
m_dataProvider.PersistPackage(ControllerID, package);
MyTrace.WriteLine("Package persisted");
m_dataProvider.PersistTransmissionControllerStatus(this);
MyTrace.WriteLine("Transmission controlled updated");
ts.Complete();
}