-> I applied service pack on one of the SQL instance in a 2 node cluster. After applying the service pack, SQL services failed to come online.
-> I applied service pack on passive node first and then on the active node. The install went fine without any issues. But after the service pack upgrade SQL server did not start.
-> Checked the SQL server error log and found that the SQL server fails during script upgrade mode with below error.
2016-12-08 23:57:25.43 spid8s DBCC execution completed. If DBCC printed error messages, contact your system administrator.
2016-12-08 23:57:25.43 spid8s Error: 537, Severity: 16, State: 3.
2016-12-08 23:57:25.43 spid8s Invalid length parameter passed to the LEFT or SUBSTRING function.
2016-12-08 23:57:25.43 spid8s Error: 912, Severity: 21, State: 2.
2016-12-08 23:57:25.43 spid8s Script level upgrade for database ‘master’ failed because upgrade step ‘sqlagent100_msdb_upgrade.sql’encountered error 537, state 3, severity 16. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
2016-12-08 23:57:25.43 spid8s Error: 3417, Severity: 21, State: 3.
2016-12-08 23:57:25.43 spid8s Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
2016-12-08 23:57:25.43 spid8s SQL Trace was stopped due to server shutdown. Trace ID = ‘1’. This is an informational message only; no user action is required.
2016-12-08 23:57:25.46 Logon Error: 18401, Severity: 14, State: 1.
2016-12-08 23:57:25.46 Logon Login failed for user ‘iuser_SitefinityFrontier’. Reason: Server is in script upgrade mode. Only administrator can connect at this time. [CLIENT: 188.8.131.52]
-> Added -T902 to stop script upgrade mode. Started the SQL services, it started without issues. Checked the owner for MSDB and Master. Both were having SA as owner.
|902||Bypasses execution of database upgrade script when installing a Cumulative Update or Service Pack.|
-> Searched for sqlagent100_msdb_upgrade.sql file and opened it.
-> The script upgrade mode was failing on below set of statement in file sqlagent100_msdb_upgrade.sql,
SELECT @device_directory = SUBSTRING(filename, 1, CHARINDEX(N’master.mdf’, LOWER(filename)) – 1) FROM master.dbo.sysaltfiles
WHERE (name = N’master’)
-> The SQL server instance did have more than one database with logical name “master”.
-> Query “”SELECT db_name(dbid) FROM master.dbo.sysaltfiles WHERE (name = N’master’)”” returned 3 databases including master database in my SQL server instance.
-> Variable @device_directory can contain only one value. But in our case 3 values were returned and thats the reason we got this error.
-> I detached the 2 databases.
-> Ran Query “”SELECT db_name(dbid) FROM master.dbo.sysaltfiles WHERE (name = N’master’)”” and it returned just master database.
-> Removed the startup parameter -T902 and started the SQL service from cluadmin.msc.
-> SQL server started this time without issues. Script upgrade mode completed fine without any issues and the version changed to appropriate value.
-> Failed over the SQL instance to other node and it came online without issues.
The views expressed on this blog are mine alone and do not reflect the views of my company or anyone else. All postings on this blog are provided “AS IS” with no warranties, and confers no rights.