本文可帮助你排查运行数据库升级脚本时 SQL Server 累积更新(CU)或 Service Pack(SP)报告错误 574 的问题。
现象
为 SQL Server 应用 CU 或 SP 时,安装程序将返回以下错误消息:
等待数据库引擎恢复句柄失败。 有关可能的原因,请查看 SQL Server 错误日志。
此外,SQL Server 错误日志中可能会记录以下错误条目以及错误 912 和 3417:
15136 The database principal is set as the execution context of one or more procedures, functions, or event notifications and cannot be dropped.
15138 The database principal owns a %S_MSG in the database, and cannot be dropped.
15141 The server principal owns one or more %S_MSG(s) and cannot be dropped.
15154 The database principal owns an %S_MSG and cannot be dropped.
15155 The server principal owns a %S_MSG and cannot be dropped.
15183 The database principal owns objects in the database and cannot be dropped.
15184 The database principal owns data types in the database and cannot be dropped.
15186 The server principal is set as the execution context of a trigger or event notification and cannot be dropped.
15284 The database principal has granted or denied permissions to objects in the database and cannot be dropped.
15421 The database principal owns a database role and cannot be dropped.
27226 The database principal has granted or denied permissions to catalog objects in the database and cannot be dropped.
33015 The database principal is referenced by a %S_MSG in the database, and cannot be dropped.
Error: 912, Severity: 21, State: 2.
Script level upgrade for database 'master' failed because upgrade step 'SSIS_hotfix_install.sql' encountered error 945, state 2, 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 Server 时,在证书中创建包含在双哈希标记(##)中的服务器主体。 这些主体将被视为系统创建的主体。 它们不得映射到拥有用户对象 msdb
的数据库主体或其他数据库中。 尝试升级 SQL Server 时,此默认配置的任何更改都可能导致失败。 这是因为升级脚本假定这些对象只有 SQL Server 创建的依赖项。
解决方法
使用 跟踪标志 902 启动 SQL Server。
若要确定服务器主体到数据库主体的映射,请运行以下命令:
EXEC master.sys.sp_helplogins
将受影响对象的所有权更改为其他用户。
重启 SQL Server 而不带跟踪标志
902
,以便升级脚本可以完成运行。
注意
尽管运行升级脚本失败是“等待数据库引擎恢复处理失败”错误的常见原因之一,但此问题也可能因其他原因而发生。 此错误意味着更新安装程序无法在安装更新后启动服务或将其联机。 在任一情况下,故障排除都涉及查看错误日志和安装日志,以确定失败原因并采取适当的措施。