It is
always annoying to see either of the replicas failing, be it a primary or a secondary.
However, Always-On Availability Group has an excellent feature to cover us from
the situation.
In this article, we will be covering as to how a synchronous or an asynchronous secondary replica resynchronizes with primary replica.
Synchronous Secondary Replica Resynchronizing With The Primary Replica
1. When
the synchronous secondary replica goes offline, its status changes from
Synchronized to 'Not Synchronizing.' Once this status change occurs, the
primary replica stops waiting for an acknowledgment from the secondary that it
has hardened a commit and begins treating it as an asynchronous replica. This
ensures that commits on the primary replica are not delayed by an unhealthy
synchronous secondary replica.
2. When
the secondary replica is brought back online, it establishes a connection with
the primary replica and sends its End of Log (EOL) Log Sequence Number (LSN) to
the primary replica.
3. Upon
receiving this, the primary replica begins sending the log blocks that were
hardened after the EOL LSN to the secondary replica.
4. As the
secondary replica starts receiving and hardening these log blocks, its status
changes to Synchronizing. This indicates that the secondary replica is
connected to the primary and is catching up, essentially functioning as an
asynchronous replica.
5. The
secondary replica continues to harden the log blocks, apply the hardened
transactions with the REDO thread, and send this information back to the
primary replica.
6. This
process continues until the Last Hardened (LH) LSN of both the primary and
secondary replicas match. Once they do, the status of the secondary replica
changes to Synchronized, and the primary replica starts treating it as a
synchronous replica.
7. The
primary replica begins waiting for an acknowledgment from the secondary replica
for the commit before informing the user that the transaction has been
committed successfully.
Asynchronous Secondary Replica Resynchronize With The Primary Replica
1. When
the asynchronous secondary replica goes offline, its status changes from
Synchronizing to 'Not Synchronizing.' The primary replica responds in the same
way.
2. Once
the secondary replica is brought back online, it establishes a connection with
the primary replica and sends its End of Log (EOL) LSN to the primary replica.
3. Upon
receiving this, the primary replica begins sending the log blocks that were
hardened after the EOL LSN to the secondary replica.
4. As soon
as the secondary replica starts receiving and hardening these log blocks, its
status changes to Synchronizing. This indicates that the secondary replica is
connected to the primary and is catching up.
Refer - Data Synchronization Modes In Always On In SQL Server
0 comments:
Post a Comment