I have read these articles few times. I do monitor potential data loss today using some of the methods described in these articles.
- Measuring Availability Group synchronization lag by Derik Hammer
- Monitor Performance for AlwaysOn Availability Groups
- Monitoring Availability Group Replica Synchronization by Jonathan Kehayias
Reading these articles and the description of dynamic management views and performance counters, I do not see any way to measure the exact time for potential data loss if Primary goes down now.
I did inquire about using log sequence number (LSN) values from
sys.dm_hadr_database_replica_states. Found out only certain LSN's has a timestamp. Plus, continuously querying the timestamp of those particular LSN is probably not a practical solution.
Do you know how to get the exact time for potential data loss at any given time?
A hypothetical solution will be finding the oldest LSN's timestamp that has not been copied to the secondary.