In a SQL Server Always On Availability Groups setup, I'm seeking guidance on determining the most up-to-date secondary replica when the primary is unavailable, to perform a failover to minimize data loss.
Assume a situation where the primary replica is down. The objective is to identify the secondary replica with the most up-to-date data in the absence of real-time communication with the primary. For that, I can't find any reliable query or metric in the SQL server.
SELECT replica_id, redo_queue_size FROM sys.dm_hadr_database_replica_states;
Is the redo_queue size a reliable indicator in scenarios where the primary replica is unavailable?
Are there alternative methods or queries to assess the data synchronization state among secondary replicas during a primary replica outage?
What considerations or best practices should be taken into account when interpreting redo_queue size or other metrics for failover decision? such as
last_hardened_lsn, end_of_log_lsn, last_commit_lsn, last_hardened_time from sys.dm_hadr_database_replica_states
In PostgreSQL, you can use the Write-Ahead Logging (WAL) position to determine the synchronization status and identify which secondary replica has the most up-to-date data. The WAL position serves as a reliable indicator of the replication progress in PostgreSQL. Is there any similar query available in MS SQL Server?
Additionally, I'm curious about how Windows Server Failover Clustering (WSFC) or Pacemaker (a cluster resource manager for Linux) decides which replica should be promoted to the primary role when the primary replica is unavailable.
I appreciate any insights, experiences, or recommendations from the community. Thank you!