Fun with the TFSServerScheduler service

Today I had a bit of an odd problem with the TFSServerScheduler service on one of my TFS 2008 machines. The machine is an ATDT install of TFS 2008 and it had been experiencing an issue where, after a reboot, the TFSServerScheduler would fail to start correctly and I would be presented with this in my System Event Log:

Event Type:            Error
Event Source:         Service Control Manager
Event Category: None
Event ID:                7023
Date:                       6/12/2008
Time:                       9:36:25 AM
User:                       N/A
Computer:              TFS08
Description:
The Visual Studio Team Foundation Server Task Scheduler service terminated with the following error:
The configuration data for this product is corrupt.  Contact your support personnel.
For more information, see Help and Support Center at go.microsoft.com/fwlink/events.asp.

Seems this is known issue, experienced most often on ATDT installs and is caused because the SQL Server instance the TFSServerScheduler service tries to connect as the machine starts up has yet to start itself (they're all on the same machine). The error message would not lead one to that conclusion at all, in my opinion, but apparently that's the cause.

Usually this problem is easily resolved by just manually starting the TFSServerScheduler service after SQL Server has kicked itself over. What if you're not there, though? What happens in the event of a power loss where the machine restarts (hopefully), or maybe SMS is installed on your network and your server is force-rebooted by the IT department after an update. In cases like these you would be left without this service running... perhaps until you noticed it (and people are yelling for fresh reports, etc.).

Anyway, I dug around a bit and found that the suggested fix for this is to just add a dependency on the TFSServerScheduler service for SQL SERVER (or "MSSQLSERVER", as the service name is labeled by default). I did that a while ago (using this info) and thought all was well - I'd be ready for the next reboot and wouldn't have to manually start the TFSServerScheduler service. I was wrong.

Today, being the day after "Patch Tuesday", I found that I had to reboot that TFS 08 machine and when I did so I was confronted with the familiar message saying "At least one service or driver failed during system startup.  Use Event Viewer to examine the event log for details." I checked the event log, thinking it couldn't possibly be the TFSServerScheduler service I had so wisely prepared for just such an occasion weeks before only to find that it was... but not for the reason I'd expected. The error this time was not about corrupted configuration data, but rather...

Event Type:            Error
Event Source:         Service Control Manager
Event Category:     None
Event ID:                7003
Date:                       7/9/2008
Time:                       10:56:52 AM
User:                       N/A
Computer:              TFS08
Description:
The Visual Studio Team Foundation Server Task Scheduler service depends on the following nonexistent service: MSSQLSERVER

For more information, see Help and Support Center at go.microsoft.com/fwlink/events.asp.

"What?!", I said to myself in dismay (actually it was a much more "colorful" exclamation, but one unsuitable for this venue <g>). "I know SQL Server is installed!" TFS can't live without it!". After calming down and thinking about it though, I came to discover that this particular machine was using a named instance for SQL Server install TFS was using (a feature we added in TFS 2008). So it was true, actually - there was no service named "MSSQLSERVER" on the machine, but rather one named "MSSQL$TFS". This was the dependency I *should* have added for my TFSServerScheduler service. With this knowledge in hand I set off blissfully to edit my registry and set things right.

I edited the REG_MULTI_SZ value "DependOnService" I had added under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\TFSServerScheduler, replacing the MSSQLSERVER entry with MSSQL$TFS. Figuring that was enough to redeem myself I ran a NET START against TFSServerScheduler from a command prompt. It failed and I was presented with this error message:

System error 1075 has occurred. The dependency service does not exist or has been marked for deletion.

A few more colorful words and thoughts later and my research lead me to discover that it was apparently not enough to just edit this information for services directly in the registry when you are in a state like this. Perhaps it is and a reboot would have cleared this up, but instead I found that I could resolve the issue by using SC.EXE, which was located in the Winnt\System32 directory on this 32-bit Windows Server 2003 machine.  I used this command to add a dependency to my TFSServerScheduler service - the correct one this time - and the issue was cleared up (yes, I rebooted to prove it <g>).

            sc.exe config TFSServerScheduler depend= MSSQL$TFSCSS

Hopes this helps if you ever put yourself in a similar situation.

Trevor Hancock