Killing a process while in a TransactionScope

  • Thread starter Thread starter gareththackeray
  • Start date Start date
G

gareththackeray

Hi,

We've been using the TransactionScope class which is great and really
makes using Transactions a doddle. However, if we kill the process in
the middle of a using(TransactionScope) block, it leaves it hanging,
seemingly indefinitely, until we restart the DTC on either client or
server.

So, I have two questions:

1. are there any techniques to force the transaction to rollback on
killing the process;

2. which of the many available timeouts controls the transaction
timeout on the DTC?

Thanks in advance,

Gareth
 
What you mean by "killing", TerminateProcess() API?
If so, there is nothing you can do about it. TerminateProcess() "freezes"
the target process immediatly. No more user mode code will run on it. No
cleanup. Nothing.

This works for me. Never seen pending transactions around for more than 35
seconds.
using (TransactionScope innerTrx = new
TransactionScope(TransactionScopeOption.Required, TimeSpan.FromSeconds(30)))
{
}

It is possible to set a global timeout for MSDTC (old doc but actual):

http://support.microsoft.com/?scid=kb;en-us;287499&x=12&y=13
 
Thanks Laura. We're seeing timeouts on transactions taking more than
20s though, which seems strange as we can't find any timeout set to
20s! We'll keep looking... In truth our database needs some tuning
so we should be able to reach the point of not getting 20s
transactions anyway.

Cheers,

Gareth
 
Back
Top