Help : Unable to start SQL Service after installing Service Pack or Cumulative Upgrade or Hotfix
Posted by blakhani on March 10, 2015
This is one of the common issue which a DBA might have seen. Let’s first understand what happens whenever an upgrade is performed for SQL Server. During installation of patch the binaries are updated, resource database is replaced. During the restart, after successful completion, the upgrade scripts are run. This is the time when Login would fail with below error.
2015-01-05 10:45:03.23 Logon Error: 18401, Severity: 14, State: 1.
2015-01-05 10:45:03.23 Logon Login failed for user ‘NT AUTHORITY\SYSTEM’. Reason: Server is in script upgrade mode. Only administrator can connect at this time. [CLIENT: <local machine>]
This error is normal for sometime till upgrade scripts have completed execution. It has been observed that sometimes, due to system configuration, the script don’t run successfully. If upgrade script has not run, SQL would shutdown automatically and below would be the message in SQL ERRORLOGs.
2015-01-05 10:45:07.94 spid9s Error: 3417, Severity: 21, State: 3.
2015-01-05 10:45:07.94 spid9s 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.
Above message is very scary and suggest you to do something which you may not want. Now, If you are into situation where upgrade is not complete, there are few things you should try. Very first thing is look at ERRORLOG and locate a place where you would find some error during script upgrade. Here are few sample errors which you might see.
Error 1 – CREATE DATABASE failed
2015-01-05 10:45:02.55 spid9s Database ‘master’ is upgrading script ‘sqlagent90_sysdbupg.sql’ from level 0 to level 2.
2015-01-05 10:45:07.94 spid9s Error: 5133, Severity: 16, State: 1.
2015-01-05 10:45:07.94 spid9s Directory lookup for the file "F:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA\temp_MS_AgentSigningCertificate_database.mdf" failed with the operating system error 3(The system cannot find the path specified.).
2015-01-05 10:45:07.94 spid9s Error: 1802, Severity: 16, State: 1.
2015-01-05 10:45:07.94 spid9s CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
2015-01-05 10:45:07.94 spid9s Error: 912, Severity: 21, State: 2.
2015-01-05 10:45:07.94 spid9s Script level upgrade for database ‘master’ failed because upgrade step ‘sqlagent90_sysdbupg.sql’ encountered error 598, state 1, severity 25. 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.
2015-01-05 10:45:07.94 spid9s Error: 3417, Severity: 21, State: 3.
2015-01-05 10:45:07.94 spid9s 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.
Okay. Problem here is that F:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\DATA folder is missing as we are getting error “The system cannot find the path specified”. The database default path is stored in registry and this is explained here. All we need to do is change the registry to correct value and start SQL Services.
Error 2 – affinity mask related error
2015-01-01 00:00:06.79 spid7s Database ‘master’ is upgrading script ‘sqlagent100_msdb_upgrade.sql’ from level 0 to level 3.
2015-01-01 00:00:06.79 spid7s —————————————-
2015-01-01 00:00:06.79 spid7s Starting execution of PREINSTMSDB100.SQL
2015-01-01 00:00:06.79 spid7s —————————————-
..
2015-01-01 00:00:06.97 spid7s Setting database option COMPATIBILITY_LEVEL to 100 for database msdb.
2015-01-01 00:00:07.01 spid7s Configuration option ‘allow updates’ changed from 1 to 1. Run the RECONFIGURE statement to install.
2015-01-01 00:00:07.01 spid7s Configuration option ‘allow updates’ changed from 1 to 1. Run the RECONFIGURE statement to install.
2015-01-01 00:00:07.01 spid7s Error: 5833, Severity: 16, State: 1.
2015-01-01 00:00:07.01 spid7s The affinity mask specified is greater than the number of CPUs supported or licensed on this edition of SQL Server.
2015-01-01 00:00:07.01 spid7s Error: 912, Severity: 21, State: 2.
2015-01-01 00:00:07.01 spid7s Script level upgrade for database ‘master’ failed because upgrade step ‘sqlagent100_msdb_upgrade.sql’ encountered error 5833, state 1, 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.
2015-01-01 00:00:07.02 spid7s Error: 3417, Severity: 21, State: 3.
2015-01-01 00:00:07.02 spid7s 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.
To fix above problem, we can start the Instance by skipping the post upgrade script by adding trace flag –T902 to the startup parameters. Steps to enable trace flag can be found in this KB Once SQL is started and we should be able to connect to SQL Server normally. Then connect via SSMS and check the checkbox “Automatically set processor affinity mask for all processors” under instance properties. This could have also been archived using the below TSQL.
ALTER SERVER CONFIGURATION SET PROCESS AFFINITY CPU = AUTO GO
Once configuration change as been done, we need to remove the trace flag and then start SQL normally. Post restart, we need to check SQL Server ERRORLOG and make sure we have below line.
Recovery is complete. This is an informational message only. No user action is required
This message during upgrade scenario means that post upgrade script have been executed successfully.
If you have encountered any error during upgrade, please comment and let me know.
Leave a Reply