如果 SSISDB 配置了 AG,则错误 945 和 SQL Server 升级失败

本文可帮助你排查运行数据库升级脚本时,Microsoft SQL Server 的累积更新(CU)或 Service Pack(SP)报告错误代码 945 时发生的问题。

现象

应用 CU 或 SP 时,安装程序将返回以下错误消息:

等待数据库引擎恢复句柄失败。 有关可能的原因,请查看 SQL Server 错误日志。

此外,可能会在 SQL Server 错误日志中记录以下错误条目:

Database 'master' is upgrading script 'SSIS_hotfix_install.sql' from level 201331031 to level 201331592.
Error: 945, Severity: 14, State: 2.
Database 'SSISDB' cannot be opened due to inaccessible files or insufficient memory or disk space. See the SQL Server errorlog for details.
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 Integration Services 目录数据库(SSISDB)添加到 AlwaysOn 可用性组(AG),脚本升级可能会失败。 升级过程在单用户模式下运行。 但是,可用性数据库必须是多用户数据库。 因此,在升级安装期间,所有可用性数据库(包括 SSISDB)都处于脱机状态,不会升级。

有关详细信息,请参阅可用性组中升级 SSISDB。

解决方法

若要解决该问题,请执行以下步骤:

  1. 从 AG 中删除 SSISDB。
  2. 在每个节点上运行 CU 升级。
  3. 升级完成后,将 SSISDB 还原到 AG。