I always keep playing with my virtual machine which has SQL Server installed. Recently I was trying to apply the patch of SQL Server and I was surprised to see that SQL Server was not getting started after patching. The error was Error 15240 it cannot write into the file.
I looked into the SQL Server ERRORLOG and found below message just before SQL shut down.
2016-12-21 17:52:15.73 spid5s Exporting ##MS_AgentSigningCertificate## to D:\MSSQL\Data\\MS_AgentSigningCertificate.cer
2016-12-21 17:52:15.73 spid5s Could not export certificate, trying again with random name. If this is a mkmastr build then this is an error.
2016-12-21 17:52:15.73 spid5s Exporting ##MS_AgentSigningCertificate## to D:\MSSQL\Data\\MS_AgentSigningCertificate663E9150-3E68-45A0-8AD8-0FE26C6020B3.cer
2016-12-21 17:52:15.73 spid5s Error: 15240, Severity: 16, State: 2.
2016-12-21 17:52:15.73 spid5s Cannot write into file ‘D:\MSSQL\Data\\MS_AgentSigningCertificate663E9151-3E68-45A0-8AD8-0FE26C6020B3.cer’. Verify that you have write permissions, that the file path is valid, and that the file does not already exist.
2016-12-21 17:52:15.73 spid5s Error: 912, Severity: 21, State: 2.
2016-12-21 17:52:15.73 spid5s Script level upgrade for database ‘master’ failed because upgrade step ‘msdb110_upgrade.sql’ encountered error 15240, state 2, 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-21 17:52:15.74 spid5s Error: 3417, Severity: 21, State: 3.
2016-12-21 17:52:15.74 spid5s 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-21 17:52:15.74 spid5s SQL Server shutdown has been initiated
2016-12-21 17:52:15.74 spid5s SQL Trace was stopped due to server shutdown. Trace ID = ‘1’. This is an informational message only; no user action is required.
One thing which is weird in error log was D:\MSSQL\DATA\\MS_AgentSigningCertificate663E9151-3E68-45A0-8AD8-0FE26C6020B3.cer
Do you see something strange? If not, notice two back slashes after DATA. This is the same folder which contains the master database file. I checked the startup parameters in ERRORLOG and found:
From above, we can confirm that there are two backslashes in the startup parameters when referring to master.mdf file.
SOLUTION / WORKAROUND
Once we removed one of the backslash and started the service without any issues. If you want to know how to modify the startup parameters, then refer to my earlier blog. SQL SERVER – Denali – Startup Parameters Easy to Configure
Have you ever had issues with such incorrect startup parameters?
Reference: Pinal Dave (https://blog.sqlauthority.com)