System.Transactions and the Silent Timeout of Death

There’s a huge whopping gaping hole of a bug in .NET 2.0 (and also by default in .NET 3.5) with the interaction between the native SqlClient and the System.Transactions code when lightweight transactions are in use.
Basically, it goes like this
  1. You start a transaction with a time out
  2. You do some work on your transacted connection
  3. The timeout triggers in the background, and
    1. The transaction gets rolled back
    2. The connection is left in the default "auto commit" mode
  4. You do some more work on what you think is your transacted connection and NO EXCEPTION GETS RAISED
  5. You go to commit or rollback and it raises an exception which says "What transaction? I already rolled it back!"

Now, go look in the database, and Shock! Horror! All the stuff you did in Step 2 has been rolled back, but all the stuff you did in step 4 is there! Half a transaction! Argh!

Go see the initial report of this bug and the admission from Microsoft and their belated and weak fix for it in this thread.


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s