In my C# application I have to perform 3 task and I am putting all within a transaction scope and I am setting transaction time out 30 minutes.
using (var scope = new TransactionScope(TransactionScopeOption.RequiresNew,
new TimeSpan(0, 30, 0)))
{
//1. Create an entry in database table
//2. call some external perl script which push data
to some table
//3. update the table (step 1) with number of records generated (step 2)
scope.Complete();
}
Usually step 2 is taking 10 minutes time to execute and step 3 is taking 5 minutes time (step 1 is real quick).
I do also set command time out for step 3 is,
sqlCom.CommandTimeout = 1800;
All 3 tasks for the transaction is completed in max 15-20, but still I am getting timeout error,
System.Transactions.TransactionAbortedException: The transaction has
aborted. ---> System.TimeoutException: Transaction Timeout
--- End of inner exception stack trace ---
at
System.Transactions.TransactionStateAborted.BeginCommit(InternalTransaction
tx, Boolean asyncCommit, AsyncCallback asyncCallback, Object asyncState)
at System.Transactions.CommittableTransaction.Commit()
at System.Transactions.TransactionScope.InternalDispose()
at System.Transactions.TransactionScope.Dispose()
Note - When steps 2 and 3 take less time (2-3 minutes average), then I am not getting any timeout error.
Please suggest if I can set something else?