SQL Server 从 SQL Server 2014 或 SQL Server 2016 升级到 2017 失败,并返回错误 1712

本文可帮助你排查并解决在执行数据库升级脚本时将 SQL Server 2016 或 SQL Server 2014 升级到 SQL Server 2017 报告 1712 的问题。

现象

在运行 ISServer_upgrade.sql 升级脚本时,升级到 SQL Server 2017 实例可能会失败,并出现以下错误:

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

检查 SQL Server 错误日志时,请注意以下错误条目之一:

2020-10-26 10:08:09.94 spid6s      Database 'master' is upgrading script 'ISServer_upgrade.sql' from level 0 to level 500. 
2020-10-26 10:08:09.94 spid6s      --------------------------------------------- 
2020-10-26 10:08:09.94 spid6s      Starting execution of ISServer_upgrade.SQL 
2020-10-26 10:08:09.94 spid6s      --------------------------------------------- 
2020-10-26 10:08:09.94 spid6s        
2020-10-26 10:08:09.94 spid6s      Taking SSISDB to single user mode 
2020-10-26 10:08:09.94 spid6s      Setting database option SINGLE_USER to ON for database 'SSISDB'. 
2020-10-26 10:08:10.47 spid6s      Error: 1712, Severity: 16, State: 1. 
2020-10-26 10:08:10.47 spid6s      Online index operations can only be performed in Enterprise edition of SQL Server. 
2020-10-26 10:08:10.47 spid6s      Error: 917, Severity: 15, State: 1. 
2020-10-26 10:08:10.47 spid6s      An upgrade script batch failed to execute for database 'master' due to compilation error. Check the previous error message for the line which caused compilation to fail. 
2020-10-26 10:08:10.47 spid6s      Error: 912, Severity: 21, State: 2. 
2020-10-26 10:08:10.47 spid6s      Script level upgrade for database 'master' failed because upgrade step 'ISServer_upgrade.sql' encountered error 917, state 1, severity 15. 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. 
2020-10-26 10:08:10.48 spid6s      Error: 3417, Severity: 21, State: 3. 
2020-10-26 10:08:10.48 spid6s      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. 
2020-10-26 10:08:10.48 spid6s      SQL Server shutdown has been initiated 
2020-10-26 10:08:10.48 spid6s      SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required. 
2020-10-26 10:08:10.50 spid15s     The SQL Server Network Interface library successfully deregistered the Service Principal Name (SPN) [ MSSQLSvc/SAFHSQL01.SAFEHAVEN.com ] for the SQL Server service. 
2020-10-26 10:08:10.50 spid15s     The SQL Server Network Interface library successfully deregistered the Service Principal Name (SPN) [ MSSQLSvc/SAFHSQL01.SAFEHAVEN.com:1433 ] for the SQL Server service.

原因

用于制造(RTM)升级脚本的 SQL Server 2017 版本包括一个动态链接库(DLL),它针对所有版本的 SQL Server 运行联机索引操作,尽管只有企业版和开发人员版本支持此功能。 有关数据库升级脚本的详细信息,请参阅 应用更新时对升级脚本失败进行故障排除。

解决方法

若要解决 1712 错误,请执行以下步骤:

  1. 将 SQL Server 与跟踪标志 (TF) 902 一起启动。 有关详细信息,请参阅 使用跟踪标志 902 启动 SQL 的步骤。

    注意

    升级二进制文件后发生此错误,SQL Server 数据库引擎已位于 SQL Server 2017 RTM 级别,你仍然可以使用 TF 902 启动实例。

  2. 安装 SQL Server 2017 CU5 或更高版本的 SQL Server 版本。

  3. 从启动参数中删除 TF 902,然后重启 SQL Server。

  4. SQL Server 在不使用 TF 902 启动后,升级脚本将再次运行。

    • 如果升级脚本成功完成,则 Service Pack (SP) 或累积更新 (CU) 升级已完成。 可以检查 SQL Server 错误日志和启动文件夹以验证已完成的安装。

    • 如果升级脚本再次失败,请检查 SQL Server 错误日志中是否有其他错误条目,然后排查新错误。