Friday, September 21, 2012

The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.

We had a WCF-SQL send port that was to insert a large data set into the database, and then execute a stored procedure when done, this can all be sent as one message to sql and it works it out.

The problem is that this took a very long time, we increased time outs but were still getting a time out every time, with the error: 

System.Data.SqlClient.SqlException: The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction.

Server stack trace:
   at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.SendAsyncResult.End(SendAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndCall(String action, Object[] outs, IAsyncResult result)
   at System.ServiceModel.Channels.ServiceChannel.EndRequest(IAsyncResult result)

Exception rethrown at [0]:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at System.ServiceModel.Channels.IRequestChannel.EndRequest(IAsyncResult result)
   at Microsoft.BizTalk.Adapter.Wcf.Runtime.WcfClient`2.RequestCallback(IAsyncResult result)

We looked around and found that the timeout for the msdtc controller was in the machine,config.

%Windows%\Microsoft.NET\Framework\v2.0.50727\CONFIG\machine.config

Or if you run 64bit.

%Windows%\Microsoft.NET\Framework64\v2.0.50727\CONFIG\machine.config

<system.transactions>
<machineSettings maxTimeout=”01:10:00″ />
</system.transactions>

You may find this already in there, we had 00:30:00 as the timeout, we increased this, and it worked.

Problem solved.