Solution: (TV)Service cannot be started db errors (1 Viewer)

MPKeith

Portal Member
September 21, 2008
16
2
Home Country
Just a like to share a tip that might help someone with a problem that is not a TVService bug per se, but does affect many services including TVService 1.1.0 final and earlier that try to access MS SQL server at system startup.

Symtoms (may vary slightly):
Event Log (System-Application) has two "Failure Audit - MSSQLSERVER - Logon" events:
"Login failed for user 'sa'. Reason: Failed to open the explicitly specified database. [CLIENT: <local machine>]"

Followed shortly after by a TVService error in the eventlog:

"Service cannot be started. Error: DatabaseUnavailableUnclassified
Gentle.Common.GentleException: The database backend (provider SQLServer) could not be reached.
Check the connection string:...
System.Data.SqlClient.SqlException: Cannot open database "MpTvDb" requested by the login. The login failed.
Login failed for user 'sa'."

Attempting to startup TVService manually after startup works perfectly without connection problems.

Cause:
This problem is very rare only if you use mssqlserver 2005 or express, but is a common problem if are using MS sql server 2008 and higher.

The problem is caused by MS Sql server 2008 performing new recovery startup checks after startup, but before individual databases like MpTvDb are online. The service dependency on sql server is not enough as it only allows TVService to know when SQL service is started, but each individual database may come online many minutes later, especially if you have other databases to bring online with large logs - by which time TVService has already tried and failed to logon.

Dirty Quick Fix Solution:
Add a delay to your TVService startup long enough for MSSQL Server to bring MpTvDb online. There is no option in TVService settings, but you can use a bat file to launch TVservice after a delay.

Longer term elegant solution: Use RequestAdditionalTime in TVService start to wait much longer than the current timeout:
windows service startup timeout - Stack Overflow

Hope this helps someone.
 

Users who are viewing this thread

Top Bottom