SharePoint Troubleshooting: User Profile Synchronization Service Stuck on starting - Availability Group

Background SharePoint 2013 Environment. For unknown reason the User Profile Synchronization Service was stopped.

After the typical checks which were selected in an article by Trevor Seward about Stuck on starting I realized that nothing helped. Even after the recreation of the User Profile Service Application (we kept the data because we have a lot of field mappings also used by 3-rd-party components) we were out of luck.

I increased the Log-Level to verbose of category 'User Profile' in the diagnostic logging in central Administration and found following exception: (Server Name Change)

Failed to set the new Service Broker on database SharePoint_UserProfileService_Sync_DB on server DBMyCompany.com\sp. Exception: The operation cannot be performed on database "SharePoint_UserProfileService_Sync_DB" because it is involved in a database mirroring session or an availability group. Some operations are not allowed on a database that is participating in a database mirroring session or in an availability group.  ALTER DATABASE statement failed.

Removing this database from the availibility group and enable the Broker by ALTER DATABASE SharePoint_UserProfileService_Sync_DB SET ENABLE_BROKER

You can verify with: SELECT is_broker_enabled FROM sys.databases WHERE name = 'SharePoint_UserProfileService_Sync_DB'

Before re-adding the db to the availibility Group start the UPS by the Autofix-Powershell Script. Remove the iisreset from that script because it is necessary.

After a while (be patient) the UPS should be up and running.

Just enable the Synchronization Timerjob.