Correct SQL Server Always On Availability Group Not Synchronizing

Problem

We had an issue with a SQL Server database in an Always On Availability Group (AOAG) where it was not synchronizing the secondary replica even though it was using the “Synchronous commit” Availability Mode for the secondary replica. This article explains how to troubleshoot and resolve:

“In this availability group, at least one secondary replica has a not synchronizing synchronization state and is not receiving data from the primary replica.”

Solution

Below is information about the AOAG that is used for this article:

  • AOAG name: AG2
  • AOAG servers:
availability group servers

Here are the properties of this AG group, where we can see it was using the Automatic seeding mode:

SQL Server Always On Availability Group Properties

SQL Server Always On Not Synchronizing Issue

Go to the AOAG dashboard in SSMS to check the AOAG health:

availability group dashboard

I found that database “File” is “Not Synchronizing” on the secondary replica (uxprsqlcc02\A22P2) and showed  warnings. This database is healthy on the primary replica (uxprsqlcc01\A22P2). We monitored this issue for more than 1 hour and it did not resolve itself. Since this database is still in use, we did our troubleshooting very carefully.

 I click on “Warnings(2)” to show the details of the warnings and found the following message: “Secondary database is not joined.”

SQL Server Always On availability group warnings

Referring to this Microsoft article, we should be able to just rejoin the database on the secondary replica to resolve the issue.

When I manually rejoined this DB on the secondary replica (uxprsqlcc02\A22P2) I got this error:

availability group join database

I checked the SQL Server error log on the primary replica and found this error message:

availability group error

This message was “The remote copy of database “File” has not had enough log backups applied to roll forward all of its files to a common point in time.” Therefore, a new log backup of database “File” can provide the latest common point in time for both the primary and secondary replicas.

I changed the Seeding mode for this secondary replica (uxprsqlcc02\A22P2) to “Manual”:

availability group properties

Then I dropped database “File” manually on the secondary replica (uxprsqlcc02\A22P2) by executing the following SQL script on uxprsqlcc02\A22P2:

USE [master]
GO
DROP DATABASE [File]
GO

After database “File” was dropped on the secondary replica (uxprsqlcc02\A22P2), I created a full backup of database “File” on the primary replica (uxprsqlcc01\A22P2):

backup database

After the full backup of database “File” finished, on the primary replica I set the Seeding mode for the secondary replica back to “Automatic”:

availability group properties

The database “File” was synchronized successfully on the secondary replica (uxprsqlcc02\A22P2) after about 5 minutes as shown below. The time will vary depending on the size of the database.

availability group dashboard

Key Takeaways

  • SQL Server Always On Availability Group had synchronization issues, showing ‘Not Synchronizing’ state on the secondary replica.
  • The problem arose because the secondary database was not joined, as indicated by the warnings in SSMS.
  • Rejoining the database failed due to insufficient log backups; a new log backup was necessary to synchronize correctly.
  • After dropping the database on the secondary replica and restoring it from a full backup, synchronization succeeded in about 5 minutes.

Next Steps

2 Comments

  1. Thank for this article. We are moving to AOAG & knowing what was happening in this scenario is good information for when we would encounter such issues. Thank you for sharing this information.

Leave a Reply

Your email address will not be published. Required fields are marked *