Hey Guys,
I had encountered the same problem with applying KB5040948 update to our SQL 2019 AG environment.
The OS and SQL patching for the secondary node is automated and ran successfully, no issues. But applying the patch to the primary node raised the following alert on startup which in turn caused the instance fail:
Script level upgrade for database 'master' failed because upgrade step 'ssis_discovery' encountered error 35262, state 4, severity 10.
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.
After several attempts to recover the system db's in the primary instance and reviewing others experience via Google search (none of those solutions resolved my issues), I advised on the following:
Connected to primary node server and opened the SSCM.
- Add -T902 in startup parameter.
- Started the SQL Server service successfully.
- Removed the SSISDB from AG on primary node instance.
- Removed -T902 from startup parameter.
- Restarted the SQL service.
- Executed below command to add SSISDB back to AG.
ALTER DATABASE SSISDB SET HADR AVAILABILITY GROUP = MyAG; |
---|
- Checked the AG dashboard and confirmed that the AG is healthy and in sync.
- Optional, monitor the environment to ensure stability.
Reference:
=================
Trace Flag 902
Using trace flag 902 is a quick workaround to bring up your SQL Server service if it fails to be started due to post upgrade script failure after installing SQL Server patch.
Please note that it is not suggested to keep your SQL Server service in this state for long since your SQL Server is in an incomplete patch installation status and considered instable for your production environment. This is because part of your SQL DLL files, MSP files or related registry key record might have already been upgraded while a few other files or metadata are not upgraded.
SSISDB with AlwaysOn
SQL Server service packs usually run in single-user mode, while an availability database must be a [multi-user ]database. Therefore, during installing a service pack, you may find all availability databases including SSISDB will be taken OFFLINE and thus fail to patch.
To address this, you can first remove SSISDB from the availability databases, then patch each node (Failover Cluster Instances have to be in the [same patch level ]), then add SSISDB back.