A Problem with Fake MARS

The past couple of days I’ve had one of those real head-scratching problems you get as a software developer from time to time – the classic intermittent problem that apparently has no explanation.

It came up quite by chance – we have a customer who for one reason or another massively underestimated the volume of transactions they were going to put through their system, as a result some parts of their system have been throwing intermittent time-out errors when they’ve been querying big datasets. As a result I had to do a quick fix to one of their modules to increase the time-out on the ADO.Net command objects to allow the queries to successfully return.

Once I’d done that, I did what we would usually do in our team and did some quick informal testing to make sure nothing else was affected, and unfortunately in those tests another part of the application started throwing intermittent SQLServerconnection errors – even more strangely these weren’t coming from the point in the code where the connection was being made, but from deep down in the ExecuteReader method. As far as the code was concerned, it should be using an existing connection – why was it trying to make a new connection now?

At this point it is probably worth discussing what the code was actually doing. In essence it is two nested database queries – the code runs through the results set of the first, and based on the contents of each row does various different things, including running other database queries. All of this was being done using multiple command objects, all created using our core database access library. Digging in to what the library was doing, it was providing a single connection, and generating the commands from that single connection. It all worked fine, except when the size of the dataset started to get big, at which point the errors started to occur.

How the underlying database actually copes with this varies. In SQLServer 2005 parlance, the code is using Multiple Active Result Sets or MARS, Oracle has no problem doing it, and it is supported against all versions of Oracle in ADO.Net. But it was only supported from SQLServer 2005 – attempting to do the same in SQLServer 2000 using the SQLServer specific provider would result in an error being thrown. However even with a SQLServer 2000 back end, if you used the ADO.Net 2.0 OleDB provider it would work, with the OleDB working some magic in between to get around the problem.

All the code in this particular application was written using the generic ADO.Net objects, the idea being that it will work with any of the ADO.Net providers. Although the database being used is SQLServer 2005 – which supports MARS – the factory object that was being created was using the OleDB provider, to connect to the SQLServer 2005 back end. After a bit of digging around I came across this useful blog posting from 2004 with a question and answer over MARS – the relevant bits are towards the end – the OleDB magic bit is that provider fakes the MARS functionality by connecting and disconnecting multiple connection objects in the background – only in very specific situations does it use the SQLServer 2005 functionality – this was what was making the connection that was causing the error! Not surprisingly, this has a big impact on performance, and it was pretty obvious that something else was going awry here as well. Interestingly the article finishes off by advising only using the SqlClient library to talk to SQLServer – the warning is pretty stark:

IMHO it means that you should ONLY use SqlClient to talk to Sql Server, the risk of running into this fake MARS behavior is too great. I have seen this “feature� (fake MARS) cost hundreds of thousands of dollars an hour in lost sales as the server was inundated with unnecessary non-pooled connection open requests.

Understanding that, it looked like something was going wrong in the MARS support with in the OleDB provider. Quite apart from that, the algorithm it was using was going to perform badly with what we were trying to do – the ideal solution would just be to drop in the SqlClient instead, but unfortunately ditching the OleDB provider and going for the SqlClient instead isn’t really an option in this situation, as the application is slotting in with a whole suite of other applications that use OleDB, so the only option was coding around the restriction to ensure that the fake MARS functionality doesn’t operate. So out goes using our database library to manage connections, and it was back to a solution where I’m manually creating a connection object for each command and cleaning them up afterwards, and this seems to have got around the problem – in order to avoid this situation I just need the fine grain control over when things are being created.

PicLens

Scanning Through my Photostream with Pic Lens

I know, I’m a total sucker for glittery user interfaces, but isn’t this 3-D flyby of my Flickr Photostream just a really cool way to browse through the pictures?

The tool that is producing the interface is called PicLens and comes in flavours for Mac and Windows, and supports the major browsers on both platforms. It’s also not limited to working with Flickr – it can do the same party trick on Google searches, Facebook galleries and a load of other sites as well, and you can even set it up your own site to show slide shows of your own pictures using the same effect.

Another Sync Option

Things seem to be moving on in the calendar synchronisation arena with the release today of an official Google solution to synchronise Outlook calendars to their online Google Calendar.

In reporting the release, whilst he said it seemed good, Scoble suggested that Plaxo was a better option as it synchronised to a whole raft of other platforms too, rather than just a single platform – he is apparently using Plaxo to link Outlook through to his Mac, and keeping his iPhone in sync too – almost the same setup that I am trying to get going. Now if you’ve read my blog recently, you’ll know that I’ve found a pretty big problem with the Plaxo synchronisation of recurring appointments – my assumption is that Scoble doesn’t have any recurring appointments in his calendar, or that he hasn’t noticed the problem…

Anyway, from my point of view using the new Google Outlook Sync on the PC end and Spanning Sync which a Mac owning friend has recommended on the other would accomplish what I need and get my calendar across, so I thought I’d give the new Google option a go.

Unfortunately the first attempt doesn’t look good. I installed the software onto the PC end, and set it going. The software has a nice little tooltip that keeps you informed as to what it is up to. The number of appointments that it was synchronising seemed about right, and it claimed to have synchronised them – unfortunately when you took a look at the result on the online Google Calendar the view for March only had three appointments of any sort – considering that this month includes Easter, there should be nearer to fifty. My first thought is that maybe there was some sort of problem with the appointments – one of the other tools I’ve tried used to run into problems if certain punctuation characters appeared in any of the text fields of an appointment – but the Google Sync didn’t report any problems.

Suffice to say, as with Plaxo I’d recommend backing everything up, and carefully looking at your calendar if you give it a try – as with any synchronisation solution it has the potential to really mess things up! I guess I might take a look once it goes through a couple of revisions, but for my current task, it’s not really up to the job.

Google Calendar – shared calendars originally uploaded by Spinstah

Quiz Question

An entirely hypothetical question here, with no basis at all in reality… really…

Your employer has a set of licenses for a particular product, which are registered on their site to your company customer number, and against a contact e-mail address. Bear in mind that any installs of the product make use of the online system via the customer number to validate the install.

The person who is the current contact address is leaving, and you are taking over being the main contact with the software supplier.

You yourself also have a personal account with the supplier under a different customer number, but against your work e-mail address. As a result when you try and change the current contact e-mail address for your companies account through the online system the supplier system won’t let you make the change because another account has the same e-mail address as it’s primary contact.

Do you:

a. Change the e-mail address on your own account to something else to enable the company account to be updated.

or

b. Merge the company customer account into your personal account taking all the licenses with you and issue new login, customer number and password instructions to all the developers.

Hot Air Balloon

Hat tip to Andrew, our choir master for this one…

A man in a hot air balloon realised he was lost. He reduced altitude and spotted a woman below.

He descended a bit more and shouted, ‘Excuse me, can you help me? I promised a friend I would meet him an hour ago, but I don’t know where I am.’

The woman below replied, ‘You’re in a hot air balloon hovering approximately 30 feet above the ground. You’re between 40 and 41 degrees north. Latitude and between 59 and 60 degrees west longitude.’

‘You must be in IT,’ said the balloonist.

‘I am,’ replied the woman, ‘How did you know?’

‘Well,’ answered the balloonist, ‘everything you told me is technically correct, but I’ve no idea what to make of your information and the fact is I’m still lost. Frankly, you’ve not been much help at all. If anything, you’ve delayed my trip.’

The woman below responded, ‘You must be in Management.’

‘I am,’ replied the balloonist, ‘but how did you know?’

‘Well,’ said the woman, ‘you don’t know where you are or where you’re going.
You have risen to where you are due to a large quantity of hot air. You made a promise, which you’ve no idea how to keep, and you expect people beneath you to solve your problems. The fact is you are in exactly the same position you were in before we met, but now, somehow, it’s MY fault.’