• behance
  • gitHub
  • google
  • linkedin
  • twitter
TeamCity CI Server Login Fails at Boot Up

TeamCity CI Server Login Fails at Boot Up

If you’re running an instance of TeamCity on your local dev box, and who isn’t eh! haha, oh for more machines.  It’s highly likely that over the last two major versions (8 and now 9) that you are often, if not always, presented with something like this after boot up:

Cannot open database “TeamCity” requested by the login. The login failed. ClientConnectionId:f17b1159-b183-4241-bc98-c119d1767b49
SQL exception: Cannot open database “TeamCity” requested by the login. The login failed. ClientConnectionId:f17b1159-b183-4241-bc98-c119d1767b49

The issue is that TeamCity tried to connect to it’s database before SQL has finished initialising.  So obviously the login is going to fail.  I see this happening on every boot, a simply flick of the switch to restart the service and we’re off.

It’s very annoying and I’ve raised a bug report twice with JetBrains, once for version 8 and once for version 9.0.4 (the very latest at the time of writing).  Might seem like a trivial problem but there are a few things that directly contribute to this issue being out of their hands.  The driver sqljdbc_4.0.2206.100_enu sqljdbc4.jar is authored by Microsoft and seem to contain a bug in that it doesn’t always report the correct state.  Meaning JetBrains cannot reply on it’s response in order to Do The Right Thing™

SO … time to break out the batch file …

The (Hopefully Temporary) Solution

Make a batch file with this in it:

net stop TeamCity && net start TeamCity

And then setup a scheduled task to run 5 minutes after bootup and runas admin, sorted.

Share

Leave a reply

*