views:

18

answers:

1

I have a unit test for some code that occasionally throws a "The transaction has already been implicitly or explicitly committed or aborted." exception. Google gives me lots of wonderful hits but none that I've read seem to apply.

If I run the unit test locally the exception is never thrown.
If I run it on the build server manually the exception is never thrown.

In fact, the only time the exception seems to get thrown is at night during an automated build and testing process where the exception is thrown about 80% of the time.

This rules out pretty much all the Google results on the subject as the problems there are usually caused by database connection issues in the transaction or firewalls.

There are no events in any of the event logs (on the build machine running the tests or the development database server) that suggest there is a problem. In fact, the only related event message I see is on the database machine-- a "MSDTC: Session idle timeout over, tearing down the session." event occurs shortly after I run a test.

I'm not sure how to continue trying to find this issue.

Are there any ways to generate details from within the code on the transaction state (I'm using C# with .NET 3.5)?

Is there any way to have the event log give me more information to help track this down?

The involved machines are a Windows 2000 Server (db) and Windows Serer 2003 (build) if this helps to find the right tools.

A: 

The test that is throwing the error is probably not where the error is.

It could be one og the tests that is run before that test that is leaving a transaction open or some other problem.

Then when the test that is run it gets an error when it contacts the MSDTC.

The way to find it is to start with just the test that fails, run that alone, it should pass. Then add the other tests one (or several) at a time until it fails.

Shiraz Bhaiji