Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The transaction has aborted

I have a multithreaded C# application where each thread has it's own set of db connections. Each thread uses TransactionScope / DTC. Sometimes, I get a "The transaction has aborted" exception. It's not from a timeout since it occurs in less than 2 seconds from starting the transaction.

Here's the stacktrace:

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() at MyNamespace.CallingMethod()

It happenes very infrequently, say once in 100,000 transactions.

Environment: Windows Server 2003 .Net 2.0 Connects to SqlServer 2005

Any ideas on why this is occuring? Thanks!

like image 440
Dan Avatar asked Aug 27 '10 15:08

Dan


4 Answers

Is this call stack from your inner-most InnerException? I you get this exceptions, there is usually (not always, though) an InnerException with more info.

My bet would be on a database deadlock.

like image 50
Andreas Paulsson Avatar answered Sep 30 '22 19:09

Andreas Paulsson


You can create a memory dump, the instruction can be found here http://blogs.msdn.com/b/joncole/archive/2007/03/29/creating-a-process-memory-dump.aspx

Then you can check with windbg to reveal what's root exception caused this issue. There are lots of useful information about how to use windbg check the managed exception.

in the mean time , you can use sql profiler to monitor if any sql error happened around the time when the exception was thrown.

like image 20
Russel Yang Avatar answered Sep 30 '22 20:09

Russel Yang


I think this is attributed to network instability. It is very infrequent, and hasn't reared it's ugly head in quite a few months now.

like image 37
Dan Avatar answered Sep 30 '22 20:09

Dan


If any of you facing this issue, please be noted that I managed to find the solution and the issue.. In the app config file, a properties for the connection string missing which was the "Enlist",.

Earlier the connection string was = <add name="HIS_Test_12" connectionString="server=OXYGEN\SQL2008ENT;database=CHIS_VN_12;UID=sa;Password=1234;Max Pool Size=100;Connect Timeout=200;" providerName="System.Data.SqlClient" />

Now the updated connection string is = <add name="HIS_Test_12" connectionString="server=OXYGEN\SQL2008ENT;database=CHIS_VN_12;UID=sa;Password=1234;Max Pool Size=100;Connect Timeout=200;Enlist=False;" providerName="System.Data.SqlClient" />

like image 27
shajeer Avatar answered Sep 30 '22 21:09

shajeer