I have helped many clients in upgrade failures via my On-Demand consulting and I am amazed to see various ways which can break SQL Server upgrade. In this blog we would learn about fixing error Script level upgrade for database ‘master’ failed because of upgrade step sqlagent100_msdb_upgrade.sql
Below are few earlier blogs which have other causes of same error:
As I mentioned in an earlier blog, we need to look at the exact error in ERRORLOG. In my client’s case, here is what I saw in ERRORLOG.
- Error: 8355, Severity: 16, State: 1.
- Server-level event notifications cannot be delivered. Either Service Broker is disabled in msdb, or msdb failed to start. Event notifications in other databases could be affected as well. Bring msdb online, or enable Service Broker.
- Error: 926, Severity: 14, State: 1.
- Database ‘msdb’ cannot be opened. It has been marked SUSPECT by recovery. See the SQL Server errorlog for more information.
- Error: 912, Severity: 21, State: 2.
- Script level upgrade for database ‘master’ failed because upgrade step ‘msdb110_upgrade.sql’ encountered error 926, 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.
- Error: 3417, Severity: 21, State: 3.
- 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.
- SQL Server shutdown has been initiated
- SQL Trace was stopped due to server shutdown. Trace ID = ‘1’. This is an informational message only; no user action is required.
I have put line number for clarity. Message in line number 7 onwards are scary and don’t trust/follow them. Upgrade failure is in line number 5 and 6. If you read complete message in line number 6, it tells error 926 encountered. Now, line number 3 is error number 926 which means database msdb can’t be opened.
As mentioned in all earlier articles, we need to start SQL Service with trace flag 902 to bypass upgrade script and fix the cause of upgrade script failures. So, here are the steps I have done.
As I mentioned earlier, first we started SQL with trace flag 902. I started SQL using trace flag 902 as below via command prompt.
NET START MSSQLSERVER /T902
For named instance, we need to use below (replace instance name based on your environment)
NET START MSSQL$INSTANCENAME /T902
As soon as SQL was started, we were able to connect because upgrade didn’t run. Now, we need to fix issue i.e. fix the reason of MSDB suspect database. In my client’s situation, we restore to last known good backup of MSDB database. Once restore was completed, we stopped SQL Service and started normally (without any trace flag). This time upgrade scripts ran fine, and SQL was up and running.
Have you faced any other upgrade script failures? I would be happy to write a blog, if not written already, with due credit.
Reference: Pinal Dave (https://blog.sqlauthority.com)