I have a readable secondary set up using ASYNCHRONOUS_COMMIT whos primary node is a transactional database server consisting of 23 databases. I need to know when all 23 databases are in a consistent commit state so I can kick off a data warehouse load using this readable secondary as a source.
one method I thought of was to query the last_commit_lsn of the dm_hadr_database_replica_states for both the primary and secondary nodes and make sure all 23last_commit_lsn's for each database are equal to each other. At that point I could start my load.
Another method was to:
ALTERAVAILABILITYGROUP [RPS-SQLPartsAG]MODIFYREPLICAON N'SQLWEB2008-14'WITH (AVAILABILITY_MODE=SYNCHRONOUS_COMMIT)
and then check the synchronization_state column of the sys.dm_hadr_database_replica_states table to make sure its equal to 'SYNCHRONIZED'
ALTERAVAILABILITYGROUP [RPS-SQLPartsAG]MODIFYREPLICAON N'SQLWEB2008-14'WITH (AVAILABILITY_MODE=ASYNCHRONOUS_COMMIT)
At this point I could start my load