System.Transactions and Timeout

Cross posting from All about Interop; System.Transactions has two timeout values that you can specify in configuration files. The default timeout for System.Transactions transactions is 1 minute.  You can set it in either app config, web config, or machine config.  (You can also set the timeout for a particular transaction programmatically within the application, by using one of the appropriate constructors for TransactionScope or CommittableTransaction).  Setting the default timeout to 30 seconds in config code looks like the following.

<configuration>
 <system.transactions>
  <defaultSettings timeout=”00:00:30″ />
 </system.transactions>
</configuration>

For System.Transactions there is also a maximum transaction timeout. It is designed to be used by the System Administrator to limit transaction timeouts. If this setting is not specified, it defaults to 10 minutes.  It cannot be overridden in code.   If the app.config timeout or the timeout specified in the constructors above exceed the maximum timeout in the machine.config, the timeout is adjusted down to the maximum timeout value. That can be specified only in machine config.  To change that you would specify the maxTimeout property of the machine settings section.  For example, this specifies 30 seconds:

<configuration>
 <system.transactions>
   <machineSettings maxTimeout=”00:00:30″ />
 </system.transactions>
</configuration>

So, for example if your app.config setting specifies a defaultSettings timeout of zero, which implies (with a screwy sort of logic) infinite timeout, or if your application code specifies a zero timeout in one of the constructors, then the actual timeout of the transaction will not be infinite – it will be bound to the setting for machineSettings maxTimeout.

For any high-throughput transactional server, The default maxTimeout setting is probably not right for you.  You’re going to want to set this pretty low.

This is for any transaction managed by DTC – that would include transactions involving SQL Server, Oracle, MQ, DB2, and so on.  If your transactions are timing out after 10 minutes and you want to know why, check these settings.

[Listening to: I Am – Bon Jovi – Have A Nice Day (03:54)]

Published by

Amit Bahree

This blog is my personal blog and while it does reflect my experiences in my professional life, this is just my thoughts. Most of the entries are technical though sometimes they can vary from the wacky to even political – however that is quite rare. Quite often, I have been asked what’s up with the “gibberish” and the funny title of the blog? Some people even going the extra step to say that, this is a virus that infected their system (ahem) well. [:D] It actually is quite simple, and if you have still not figured out then check out this link – whats in a name?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: