TransactionScope and Serializable

When using transaction scopes and SQL connections I recently tripped over a undesirable effect. By default when creating a new transaction scope the connection is raised to serializable. I can see the logic in this, as it provides the safest starting point and allows the developer to change the behaviour after careful consideration.

A quick explanation of serializable isolation level : Transactions occur isolated and sequential. However this is just an illusion and other transactions maybe running alongside but only if the database can maintain the fa├žade of running in an isolated manner.

I first noticed the issue when monitoring the connection pool, there were many connections that had an isolation level above what I expected, it turns out that once the isolation level was raised by enlisting in the transaction scope the isolation was not being set back to read committed.

To work around this you need to Execute “SET TRANSACTION ISOLATION LEVEL” on the connection before releasing, or turn off connection pooling (Which I wouldn’t recommend without a very good reason, establishing a database connection is an expensive operation).


Saving SSD space and Mac OSX Lion

Recently I brought a new top of the line Macbook Pro and I’m very happy with it. But with prices being what they are I opted for the 128 gig SSD. I’ve moved all non essential files elsewhere and about ready to install windows 7 for my normal development environment.

While analyzing used space on the harddisk I noticed a 4.2 gig file sitting in /private/var/vm, sleepimage.

It turns out that this file is always the slightly larger than the amount of RAM in your machine, and isn’t really required for machines with SSD’s installed. Infact it can damage the life of the SSD.

As with anything like this I can’t be held responsible for any damage blah blah blah :-).

From Terminal:

  • $ pmset -g | grep hibernatemode (Hopefully the mode is set to 3, if not then don’t continue).
  • $ sudo pmset -a hibernatemode 0
  • cd /var/vm
  • sudo rm sleepimage

You should now have reclaimed some valuable space.