Saturday, March 24, 2012

The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction

There are many times I have encountered issues with DTC when working with BizTalk and SQL. In most of the cases either DTC isn't running or configured properly or some sort of security mismatch between the client and server DTC.

But recently, I seen some warings in eventlog wheneven I am enabling my SQL receive location and finally it gets disabled as SQL adapter didn't recover from the failures but this time the reason for these error wasn't any of them mentioned above.

Following are the warnings I was getting in windows eventlog:
HRESULT="0x80040e14" Description="The Microsoft Distributed Transaction Coordinator (MS DTC) has cancelled the distributed transaction." - Most of the time

Fewer times I got the following errors/ warning:
1. Distributed transaction completed. Either enlist this session in a new transaction or the NULL transaction
2. Transaction count after EXECUTE indicates that a COMMIT or ROLLBACK TRANSACTION statement is missing. Previous count = 1, current count = 0
3. Cannot roll back . No transaction or savepoint of that name was found

I was tired of watching Abort Transaction Counts on MSDTC :(

Root cause:
In our case, we are calling an wrapper stored procedure which houses the call to 6-7 other stored procedures and one of the Stored procedure was giving an error and transactions were not handled in the right manner.
Strange thing is that, this time the orginal error is getting suppressed because of further issues in transactions which made me really running like headless chinken to look where exactly the issue is. All I was looking at the possiblities near DTC and BizTalk.
It was SQL store procedure that was the real culprit.
So I've learnt its better to use the default isolation level(serializable) of SQL Adapter but if are overriding it in Stored procedure handle transactions very carefully and remember good exception handling mechanism is key of solving the issue faster.. really fast..:)
Gud Luck

No comments:

Post a Comment