Edit

Issues when upgrading to SQL Server 2022

Applies to:  SQL Server 2022, SQL Server 2019, SQL Server 2017, SQL Server 2016

Summary

This article describes common issues you can encounter when you upgrade to SQL Server 2022, and provides resolutions and workarounds for each. The scenarios covered include access violation dumps tied to lightweight query profiling, blocked upgrades caused by a partial SQL Server installation, failover cluster instances (FCI) that fail to come online after upgrade, and replication upgrade script errors when the distribution database is part of an Always On availability group (AG). Use this guide to troubleshoot a failed in-place upgrade to SQL Server 2022 and to get your SQL Server instance back online.

Access violation dumps during upgrade in an Always On environment

This error occurs when you upgrade to SQL Server 2022 in an Always On environment. The error message and the associated log entries indicate a fatal exception generated during the upgrade process.

Error message

Exception Code: c0000005 EXCEPTION_ACCESS_VIOLATION

Application event log

Error: A user request from the session with SPID <SPID> generated a fatal exception. SQL Server is terminating this session.
Information: Windows Error Reporting - Fault bucket INVALID_REQUEST, type 0

SQL Server error log

Error: A user request from the session with SPID <SPID> generated a fatal exception. SQL Server is terminating this session. Contact Product Support Services with the dump produced in the log directory.

Solution

This problem is a known issue with LIGHTWEIGHT_QUERY_PROFILING in SQL Server 2022.

The problem is fixed in Cumulative Update 4 for SQL Server 2022 and Cumulative Update 20 for SQL Server 2019.

Workaround

If you can't apply the cumulative update yet, turn off LIGHTWEIGHT_QUERY_PROFILING. Lightweight profiling is turned off at the database level by using the LIGHTWEIGHT_QUERY_PROFILING database scoped configuration:

ALTER DATABASE SCOPED CONFIGURATION SET LIGHTWEIGHT_QUERY_PROFILING = OFF;

Upgrade blocked by an inactive SQL Server 2022 instance

You can't upgrade to SQL Server 2022 because the computer has an inactive SQL Server 2022 instance.

Cause

This problem occurs when a previous SQL Server installation fails and leaves a partially installed instance on the computer. The SQL Server setup program doesn't automatically roll back the installation when a failure occurs. The partially installed instance doesn't include the edition of SQL Server you were trying to install, which causes later installation attempts for the same version to fail.

Solution

Follow the steps in Remove a partial installation of SQL Server, and then restart the upgrade.

Failover cluster instance fails to come online after upgrade

After you upgrade SQL Server from an earlier version to SQL Server 2022 on a failover cluster instance (FCI), the instance can fail to come online. In Failover Cluster Manager, the SQL Server role shows as failed and the instance doesn't start.

Cause

The SQL Server instance is stuck in script upgrade mode, which prevents it from starting. During an upgrade, SQL Server runs upgrade scripts as part of the startup sequence. If one of those scripts fails or doesn't finish, the instance stays in script upgrade mode and can't come online.

Workaround

To bring the SQL Server instance online, bypass the running upgrade script by following the steps in Troubleshoot upgrade script failures when applying an update.

Note

The -T902 trace flag turns off upgrade script execution during startup. Remove the trace flag after you fix the underlying upgrade script issue so that the pending upgrade steps can complete.

Replication upgrade script error when the distribution database is in an availability group

A replication error occurs when you upgrade to SQL Server 2022 on a server that hosts the distribution database in an availability group (AG).

Note

This issue can also occur when you upgrade SQL Server from version 2016 SP2 CU3, SQL Server 2017 CU6, or later versions to SQL Server 2019. The fix for this issue is available in Cumulative Update 21 for SQL Server 2019.

Error message

SQL Server setup completes but shows the error "There was an error executing the replication upgrade scripts" for the replication component. If you run a repair on an instance in this state, you get the same error message.

SQL Server error log

Executing sp_vupgrade_replication.
Could not open distribution database <distribution_db_name> because it is offline or being recovered. Replication settings and system objects could not be upgraded. Be sure this database is available and run sp_vupgrade_replication again.
Error executing sp_vupgrade_replication.
Saving upgrade script status to 'SOFTWARE\Microsoft\MSSQLServer\Replication\Setup'.

Cause

The error occurs when the distribution database is part of an AG, and an in-place upgrade is attempted.

Solution

The fix is available in Cumulative Update 5 for SQL Server 2022.

Workaround

If you can't apply the cumulative update, use these steps:

  1. Remove the distribution database from the AG.
  2. Run the upgrade to SQL Server 2022.
  3. After the upgrade finishes, add the distribution database back to the AG.