Override the System.Transactions default timeout of 10 minutes in the code

Problem :

We were using System.Transactions to initiate distributed transactions against SQL Server. The transaction were getting aborted after about 10 minutes even though the System.Transactions has a timeout set to 200 minutes.

DTC timeout (in the Component Services) is set to 0 (infinite) on both app server and sql server.

DTCTrace.log from app server :
===============================
pid=3680 ;tid=5376 ;time=03/07/2008-08:20:22.717 ;seq=6 ;eventid=TRANSACTION_BEGUN ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a ;"transaction got begun description : '<NULL>'"
pid=3680 ;tid=4404 ;time=03/07/2008-08:20:24.389 ; seq=7 ;eventid=TRANSACTION_PROPOGATED_TO_CHILD_NODE ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a ;"transaction propagated to '<SQL Server machine name>' as transaction child node #1"
pid=3680 ;tid=1596 ;time=03/07/2008-08:30:24.217 ;seq=8 ;eventid=RECEIVED_ABORT_REQUEST_FROM_BEGINNER ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a ;"received request to abort the transaction from beginner"

pid=3680 ;tid=1596 ;time=03/07/2008-08:30:24.217 ;seq=9 ;eventid=TRANSACTION_ABORTING ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a;"transaction is aborting"
pid=3680 ;tid=1596 ;time=03/07/2008-08:30:24.217 ;seq=10;eventid=CHILD_NODE_ISSUED_ABORT ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a ;"abort request issued to transaction child node #1 'ASSURITYFS001'"
pid=3680 ;tid=4404 ;time=03/07/2008-08:30:24.217 ;seq=11;eventid=CHILD_NODE_ACKNOWLEDGED_ABORT ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a ;"received acknowledgement of abort request from transaction child node #1 'ASSURITYFS001'"

pid=3680 ;tid=4404 ;time=03/07/2008-08:30:24.217 ;seq=12;eventid=TRANSACTION_ABORTED ;tx_guid=a49298cd-709a-4fbe-a637-2fc6c4ab029a ;"transaction has been aborted"

Resolution :

By default all the distributed transactions initiated using System.Transactions have the default timeout of 10 minutes. If we try to override this timeout in the code or in the app.config file it will be adjusted down to 10 minutes. To get around the problem :

1. Added the following section in the machine.config file to set the maxTimeout to 1 hour :

<configuration>
 <system.transactions>
   <machineSettings maxTimeout="01:00:00" />
 </system.transactions>
</configuration> 

2. We modified the System.Transactions section in machine.config by setting the allowExeDefinition attribute to “MachineToApplication” (from MachineOnly). After this, we were able to override the machine.config timeout of 10 minutes in the code and that allowed the transaction to complete successfully.

 <sectionGroup name="system.transactions" type="System.Transactions.Configuration.TransactionsSectionGroup, System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null">
      <section name="defaultSettings" type="System.Transactions.Configuration.DefaultSettingsSection, System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
      <section name="machineSettings" type="System.Transactions.Configuration.MachineSettingsSection, System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" allowDefinition="MachineOnly" allowExeDefinition="MachineToApplication" />
    </sectionGroup>