Home
%3CLINGO-SUB%20id%3D%22lingo-sub-386059%22%20slang%3D%22en-US%22%3EReplica%20Failover%20within%20the%20Secondary%20Availability%20Group%20in%20a%20Distributed%20Availability%20Group%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-386059%22%20slang%3D%22en-US%22%3E%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Jan%2009%2C%202019%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20A%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fsql%2Fdatabase-engine%2Favailability-groups%2Fwindows%2Fdistributed-availability-groups%3Fview%3Dsql-server-2017%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20noopener%20noreferrer%22%3E%20distributed%20availability%20group%20%3C%2FA%3E%20(distributed%20AG)%20is%20a%20special%20type%20of%20availability%20group%20that%20spans%20two%20availability%20groups.%20This%20blog%20will%20clarify%20some%20issues%20regarding%20failover%20in%20a%20distributed%20AG%2C%20specifically%20demonstrates%20distributed%20AG%20resiliency%20from%20data%20loss%20despite%20the%20synchronizing%20state%20between%20the%20availability%20groups.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20A%20simple%20distributed%20AG%20%E2%80%98TIWENDAG%E2%80%99%20is%20created%20for%20relevant%20tests%20that%20will%20be%20addressed%20later%20in%20this%20blog.%20The%20structure%20of%20%E2%80%98TIWENDAG%E2%80%99%20is%20illustrated%20by%20the%20following%20diagram.%20%E2%80%98TIWENAG1%E2%80%99%20is%20the%20primary%20AG%20of%20distributed%20AG%20%E2%80%98TIWENDAG%E2%80%99%2C%20with%20%E2%80%98TIWENVM1%E2%80%99%20as%20the%20primary%20replica%20and%20%E2%80%98TIWENVM2%E2%80%99%20as%20the%20secondary%20replica.%20%E2%80%98TIWENAG2%E2%80%99%20is%20the%20secondary%20AG%20of%20the%20distributed%20AG%2C%20with%20%E2%80%98TIWENVM3%E2%80%99%20as%20the%20primary%20replica%20and%20%E2%80%98TIWENVM4%E2%80%99%20as%20the%20secondary%20replica.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98900i8D763704C54A5BFF%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20Automatic%20failover%20of%20the%20two%20availability%20groups%20defined%20in%20the%20distributed%20AG%20is%20supported.%20For%20example%2C%20if%20%E2%80%9Cautomatic%E2%80%9D%20is%20specified%20for%20failover%20mode%20in%20availability%20group%20TIWENAG1%2C%20then%20automatic%20failover%20can%20occur%20between%20TIWENAG1%20(primary)%20and%20TIWENAG2%20(synchronous%20secondary)%20in%20the%20event%20that%20TIWENAG1%20goes%20down.%20Similarly%2C%20in%20availability%20group%20TIWENAG2%2C%20in%20the%20event%20TIWENVM3%20(primary)%20goes%20down%2C%20it%20can%20automatically%20failover%20to%20TIWENVM4%20(synchronous%20secondary).%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20the%20primary%20replica%20in%20the%20AG%20(no%20matter%20whether%20the%20AG%20is%20part%20of%20a%20distributed%20AG)%20will%20automatically%20failover%20to%20a%20synchronous%20secondary%20replica%20when%20the%20primary%20replica%20goes%20down.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20If%20the%20primary%20replica%20on%20the%20secondary%20AG%20(also%20known%20as%20the%20%E2%80%9Cforwarder%E2%80%9D)%20is%20lost%20and%20causes%20automatic%20failover%20to%20happen%20or%20manual%20failover%20is%20performed%20in%20the%20secondary%20AG%20in%20a%20distributed%20AG%2C%20there%20will%20be%20no%20data%20loss%20if%20the%20following%20conditions%20are%20met%3A%20%3CBR%20%2F%3E%3CUL%3E%3CBR%20%2F%3E%3CLI%3EThe%20primary%20replica%20on%20the%20primary%20AG%20(which%20is%20usually%20referred%20to%20as%20%22global%20primary%22)%20is%20successfully%20synchronizing%20with%20the%20forwarder%20replica%20in%20the%20secondary%20AG%20over%20their%20database%20mirroring%20endpoints.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EThe%20forwarder%20replica%20in%20the%20secondary%20AG%20is%20successfully%20synchronizing%20with%20the%20secondary%20replica%20in%20the%20secondary%20AG%20over%20their%20database%20mirroring%20endpoints.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FUL%3E%3CBR%20%2F%3E%20Assume%20that%20the%20hardened%20LSN%20on%20the%20global%20primary%2C%20%E2%80%9CTIWENVM1%E2%80%9D%2C%20is%2010%3A15%3A1.%20The%20secondary%20replica%20of%20the%20primary%20AG%2C%20%E2%80%9CTIWENVM2%E2%80%9D%2C%20is%20synchronous%2C%20and%20its%20hardened%20LSN%20is%20also%2010%3A15%3A1.%20For%20the%20secondary%20AG%2C%20between%20the%20primary%20AG%20and%20the%20forwarder%2C%20synchronization%20mode%20is%20asynchronous%2C%20and%20the%20hardened%20LSN%20of%20the%20forwarder%2C%20%E2%80%9CTIWENVM3%E2%80%9D%2C%20is%2010%3A12%3A1.%20The%20secondary%20replica%20of%20the%20secondary%20AG%2C%20%E2%80%9CTIWENVM4%E2%80%9D%2C%20is%20not%20yet%20synchronized%20and%20its%20hardened%20LSN%20is%2010%3A10%3A1.%20Globally%20across%20the%20two%20AGs%20in%20the%20distributed%20AG%2C%20replica%20%E2%80%9CTIWENVM4%E2%80%9D%20has%20the%20smallest%20value%20of%20hardened%20LSN%2C%20truncation%20LSN%20on%20the%20global%20primary%20won%E2%80%99t%20go%20beyond%20this%20smallest%20value.%20In%20the%20event%20that%20%E2%80%9CTIWENVM3%E2%80%9D%20is%20lost%20and%20%E2%80%9CTIWENVM4%E2%80%9D%20becomes%20the%20new%20forwarder%2C%20it%20will%20be%20able%20to%20synchronize%20with%20the%20primary%20AG.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98901i49DBB6CEAA4FCBB7%22%20%2F%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20The%20reason%20for%20this%20is%20that%20when%20the%20transaction%20logs%20are%20backed%20up%2C%20only%20the%20logs%20that%20have%20been%20applied%20to%20all%20the%20replicas%20in%20the%20distributed%20AG%20(including%20the%20replicas%20in%20both%20AGs)%20will%20be%20truncated.%20The%20following%20table%20provides%20an%20example%20of%20how%20the%20transaction%20logs%20will%20be%20truncated%20in%20a%20distributed%20AG%2C%20using%20the%20test%20environment%20described%20at%20the%20beginning%20of%20this%20post.%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20This%20scenario%20can%20be%20easily%20demonstrated.%20The%20steps%20are%20as%20following%3A%20%3CBR%20%2F%3E%3COL%3E%3CBR%20%2F%3E%3CLI%3ERecord%20the%20current%20truncation_lsn%20and%20last%20hardened%20LSN%20of%20each%20replica.%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3EModify%20the%20database.%20Here%20an%3CCODE%3E%0A%20%20%20%20%20INSERT%0A%20%20%20%20%3C%2FCODE%3E%0A%20%20%20%20query%20is%20executed%2010%20times%20on%20the%20%E2%80%9Ctest%E2%80%9D%20database.%0A%20%20%20%3C%2FLI%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CLI%3E%0A%20%20%20%20Verify%20that%20the%20last%20hardened%20LSN%20of%20each%20replica%20grows%20by%20the%20same%20number.%0A%20%20%20%3C%2FLI%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CLI%3E%0A%20%20%20%20Do%20a%20transaction%20logs%20back%20up%20on%20the%20%E2%80%9Ctest%E2%80%9D%20database%20on%20the%20global%20primary.%0A%20%20%20%3C%2FLI%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CLI%3E%0A%20%20%20%20Verify%20current%20truncation_lsn%20and%20last%20hardened%20LSN%20.%0A%20%20%20%3C%2FLI%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CLI%3E%0A%20%20%20%20Suspend%20data%20movement%20on%20the%20secondary%20replica%20on%20the%20secondary%20AG.%0A%20%20%20%3C%2FLI%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20%3CLI%3E%0A%20%20%20%20Repeat%202-5.%0A%20%20%20%3C%2FLI%3E%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%3C%2FOL%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20The%20following%20screenshots%20record%20a%20complete%20repro%20of%20the%20scenario.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step1%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20DMVs%20used%20in%20this%20step%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20USE%20test%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20SELECT%20COUNT(*)%20AS%20'%23%20of%20transaction%20logs'%20FROM%20fn_dblog(null%2C%20null)%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20SELECT%20database_id%2C%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20group_id%2C%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20replica_id%2C%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20is_local%2C%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20is_primary_replica%2C%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20truncation_lsn%2C%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20last_hardened_lsn%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20FROM%20sys.dm_hadr_database_replica_states%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20WHERE%20database_id%3D6%20AND%20is_local%3D1%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20SELECT%20replica_id%2C%20replica_server_name%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20FROM%20sys.availability_replicas%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20WHERE%20replica_id%3D%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20(SELECT%20replica_id%20FROM%20sys.dm_hadr_database_replica_states%20WHERE%20database_id%3D6%20AND%20is_local%3D1)%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20SELECT%20COUNT(*)%20AS%20'%23%20of%20entries%20in%20testt1%20table'%20FROM%20testt1%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Results%20from%20the%20four%20replicas%20%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20primary%20AG%20(global%20primary)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98902i9C4562A987A50870%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20primary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98903i977039CC769EDDC2%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20secondary%20AG%20(forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98904i9F74E5D89DDF8207%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20secondary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98905i4080B6E6A31BE835%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20If%20all%20the%20replicas%20are%20synchronized%2C%20all%20the%20replicas%20should%20have%20the%20same%20number%20of%20transaction%20logs%20as%20well%20as%20the%20same%20truncation_lsn%20as%20in%20the%20test%20environment%20shown%20in%20the%20screenshots%20above.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step%202%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Execute%20an%0A%20%20%3CCODE%3E%0A%20%20%20INSERT%0A%20%20%3C%2FCODE%3E%0A%20%20clause%2010%20times.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20INSERT%20INTO%20testt1%20(NAME%2C%20ID)%20VALUES%20('John%20Smith'%2C%201)%0A%20%20%20%3CBR%20%2F%3E%0A%20%20%20GO%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step%203%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20primary%20AG%20(global%20primary)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98906i92E887B526CD2978%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20primary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98907i189205E51F0CD505%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20secondary%20AG%20(forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98908i774814B041799E2A%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20secondary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98909i1168969DB61BB24A%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20The%20size%20of%20transaction%20logs%20grows%20due%20to%20the%0A%20%20%3CCODE%3E%0A%20%20%20INSERT%0A%20%20%3C%2FCODE%3E%0A%20%20executions.%20The%20increase%20of%20entries%20in%20the%20%E2%80%98test%E2%80%99%20database%20also%20reflects%20that%2010%20rows%20are%20inserted%20into%20the%20table.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step%204%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Perform%20a%20transaction%20log%20backup%20on%20the%20global%20primary.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98910i310B0E707013E5E5%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step%205%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20primary%20AG%20(global%20primary)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98911iD492178DB298D778%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20primary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98912i871E398718726471%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20secondary%20AG%20(forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98913i93A166F1F1E86CDF%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20secondary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98914iF72804724EE38168%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Truncation_lsn%20of%20each%20replica%20should%20grow%20to%20the%20current%20lsn%2C%20and%20the%20number%20of%20transaction%20logs%20should%20shrink%20by%20the%20same%20size%20as%20the%20t-logs%20have%20been%20truncated.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step%206%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Suspend%20data%20movement%20of%20%E2%80%98test%E2%80%99%20database%20on%20the%20secondary%20replica%20on%20the%20secondary%20AG.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98915iEF280DDE7F7E86D2%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CSTRONG%3E%0A%20%20%20Step%207%20-%0A%20%20%3C%2FSTRONG%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20After%20repeating%20step%202%20and%203%2C%20we%20can%20see%20that%20except%20for%20the%20secondary%20replica%20on%20the%20secondary%20AG%20(TIWENVM4)%2C%20the%20%E2%80%98test%E2%80%99%20database%20on%20all%20other%20three%20replicas%20are%20modified%20again%20and%20another%2010%20entries%20are%20inserted%20into%20the%20table.%20The%20database%20on%20secondary%20replica%20on%20the%20secondary%20AG%20is%20not%20updated%20because%20the%20data%20movement%20has%20been%20suspended.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20primary%20AG%20(global%20primary)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98916i2E09917D114D69B8%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20primary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98917i58ADEDFEE0EB39D7%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20secondary%20AG%20(forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98918i35C532B5937F6BD3%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20secondary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98919i3FBF8818C817F020%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20The%20results%20from%20repeating%20step%204%20and%205%20are%20shown%20below.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20primary%20AG%20(global%20primary)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98920iFDDE51D9B77A9FAB%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20primary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98921iD563FB68B5B9F943%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20secondary%20AG%20(forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98922iA142CA697121F855%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20secondary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98923iA4481FE4DD9505BF%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Note%20that%20the%20newly%20generated%20transaction%20logs%20were%20truncated%20on%20the%20secondary%20replica%20on%20the%20primary%20AG%2C%20but%20the%20truncation_lsn%20of%20the%20primary%20replica%20on%20the%20primary%20didn%E2%80%99t%20change%20after%2010%20new%20rows%20were%20inserted%20into%20the%20database%20and%20executing%20transaction%20logs%20back%20up.%20As%20mentioned%20earlier%2C%20this%20is%20because%20the%20secondary%20replica%20on%20the%20secondary%20AG%20of%20the%20distributed%20AG%20(TIWENVM4)%20is%20not%20yet%20synchronized%20and%20thus%20has%20not%20successfully%20applied%20the%20new%20transaction%20logs%20generated%20by%20the%0A%20%20%3CCODE%3E%0A%20%20%20INSERT%0A%20%20%3C%2FCODE%3E%0A%20%20queries.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20The%20global%20primary%20of%20a%20distributed%20AG%20only%20truncates%20logs%20to%20the%20least%20LSN%20among%20all%20the%20replicas%20in%20the%20distributed%20AG.%20This%20logic%20guarantees%20that%20there%E2%80%99ll%20be%20no%20data%20loss%20when%20the%20forwarder%20got%20lost%20even%20when%20the%20secondary%20replica%20on%20the%20secondary%20AG%20has%20not%20fully%20synchronized%20with%20the%20forwarder%2C%20as%20long%20as%20the%20global%20primary%20is%20in%20a%20healthy%20state%20and%20can%20communicate%20with%20the%20secondary%20replica%20on%20the%20secondary%20AG%20properly.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20To%20simulate%20the%20scenario%20mentioned%20above%2C%20we%20shut%20down%20the%20network%20of%20the%20primary%20replica%20on%20the%20secondary%20AG%20(TIWENVM3)%20so%20that%20it%20becomes%20unavailable%20before%20we%20resume%20the%20data%20movement%20on%20the%20secondary%20replica%20on%20the%20secondary%20AG%20(TIWENVM4).%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98924i9837D0A1BB16D0A8%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20After%20the%20data%20movement%20of%20%E2%80%98test%E2%80%99%20database%20on%20TIWENVM4%20is%20resumed%2C%20the%20secondary%20AG%20(TIWENAG2)%20is%20now%20in%20a%20resolving%20state%20because%20the%20current%20primary%20replica%20on%20TIWENAG2%2C%20TIWENVM3%2C%20fails%20to%20be%20connected.%20To%20fix%20this%20issue%2C%20a%20failover%20needs%20to%20be%20performed.%20Under%20the%20scenario%20when%20in%20the%20secondary%20AG%20of%20a%20distributed%20AG%2C%20the%20forwarder%20is%20not%20available%2C%20the%20only%20failover%20option%20to%20the%20secondary%20replica%20of%20the%20secondary%20AG%20is%0A%20%20%3CCODE%3E%0A%20%20%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CCODE%3E%0A%20%20%20ALTER%20AVAILABILITY%20GROUP%20TIWENAG2%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20After%20performing%20failover%20with%0A%20%20%3CCODE%3E%0A%20%20%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20on%20the%20secondary%20replica%20on%20the%20secondary%20AG%20(TIWENVM4)%2C%20the%20database%20is%20synced%20even%20though%20the%20previous%20forwarder%20is%20currently%20unavailable%2C%20as%20the%20global%20primary%20keeps%20track%20of%20the%20unsynchronized%20part%20of%20transaction%20logs%20of%20the%20secondary%20replica%20on%20the%20secondary%20AG.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98925iB6CDF5328E94C4ED%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20In%20this%20scenario%2C%20though%20the%20only%20failover%20option%20is%0A%20%20%3CCODE%3E%0A%20%20%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20%2C%20there%E2%80%99s%20no%20data%20loss%20during%20the%20failover.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20One%20thing%20worth%20notice%20is%20that%20after%0A%20%20%3CCODE%3E%0A%20%20%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20and%20the%20previous%20primary%20replica%20(in%20this%20case%2C%20TIWENVM3)%20is%20brought%20back%2C%20data%20movement%20will%20not%20resume%20automatically%20and%20needs%20to%20be%20resumed%20manually.%20This%20behavior%20is%20by%20design%20and%20not%20limited%20to%20the%20distributed%20AG%20scenario%20but%20applies%20whenever%20failover%20with%0A%20%20%3CCODE%3E%0A%20%20%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20is%20performed.%20This%20is%20because%20there%20might%20be%20difference%20and%20even%20conflicts%20between%20the%20previous%20primary%20replica%20and%20the%20new%20primary%20replica%2C%20and%20user%20needs%20to%20manually%20choose%20which%20version%20to%20keep.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98926i9DF2E2C3B1FA1739%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20After%20resuming%20data%20movement%20on%20TIWENVM3%2C%20all%20replicas%20on%20the%20distributed%20AG%20are%20synchronized%20and%20the%20transaction%20logs%20get%20truncated%20to%20the%20same%20point.%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Primary%20replica%20on%20primary%20AG%20(global%20primary)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98927iD032AECD995B8A15%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20Secondary%20replica%20on%20primary%20AG%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98928i541D6B49A9EEBE83%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20(New)%20Secondary%20replica%20on%20secondary%20AG%20(former%20forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98929iA49761E23DA0A853%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20(New)%20Primary%20replica%20on%20secondary%20AG%20(new%20forwarder)%3A%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F98930i11AEF55CF5FC2764%22%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20%3CBR%20%2F%3E%0A%20%20It%20needs%20to%20be%20clarified%20that%20though%20under%20this%20scenario%2C%0A%20%20%3CCODE%3E%0A%20%20%20FORCE_FAILOVER_ALLOW_DATA_LOSS%0A%20%20%3C%2FCODE%3E%0A%20%20in%20the%20secondary%20AG%20doesn%E2%80%99t%20cause%20data%20loss%2C%20it%E2%80%99s%20not%20guaranteed%20that%20there%E2%80%99ll%20be%20no%20data%20loss%20when%20using%20this%20option%20to%20perform%20failover%20in%20a%20distributed%20AG.%20For%20example%2C%20if%20the%20primary%20AG%20is%20lost%2C%20there%20might%20be%20data%20loss%20when%20a%20force%20failover%20is%20performed%20in%20the%20secondary%20AG.%20This%20behavior%20is%20expected%2C%20and%20the%20cases%20that%20might%20cause%20data%20loss%20are%20not%20limited%20to%20this%20example.%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-386059%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Jan%2009%2C%202019%20A%20distributed%20availability%20group%20(distributed%20AG)%20is%20a%20special%20type%20of%20availability%20group%20that%20spans%20two%20availability%20groups.%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-386059%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3ESQLServerTiger%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Microsoft
First published on MSDN on Jan 09, 2019
A distributed availability group (distributed AG) is a special type of availability group that spans two availability groups. This blog will clarify some issues regarding failover in a distributed AG, specifically demonstrates distributed AG resiliency from data loss despite the synchronizing state between the availability groups.

A simple distributed AG ‘TIWENDAG’ is created for relevant tests that will be addressed later in this blog. The structure of ‘TIWENDAG’ is illustrated by the following diagram. ‘TIWENAG1’ is the primary AG of distributed AG ‘TIWENDAG’, with ‘TIWENVM1’ as the primary replica and ‘TIWENVM2’ as the secondary replica. ‘TIWENAG2’ is the secondary AG of the distributed AG, with ‘TIWENVM3’ as the primary replica and ‘TIWENVM4’ as the secondary replica.



Automatic failover of the two availability groups defined in the distributed AG is supported. For example, if “automatic” is specified for failover mode in availability group TIWENAG1, then automatic failover can occur between TIWENAG1 (primary) and TIWENAG2 (synchronous secondary) in the event that TIWENAG1 goes down. Similarly, in availability group TIWENAG2, in the event TIWENVM3 (primary) goes down, it can automatically failover to TIWENVM4 (synchronous secondary).

the primary replica in the AG (no matter whether the AG is part of a distributed AG) will automatically failover to a synchronous secondary replica when the primary replica goes down.

If the primary replica on the secondary AG (also known as the “forwarder”) is lost and causes automatic failover to happen or manual failover is performed in the secondary AG in a distributed AG, there will be no data loss if the following conditions are met:

  • The primary replica on the primary AG (which is usually referred to as "global primary") is successfully synchronizing with the forwarder replica in the secondary AG over their database mirroring endpoints.

  • The forwarder replica in the secondary AG is successfully synchronizing with the secondary replica in the secondary AG over their database mirroring endpoints.


Assume that the hardened LSN on the global primary, “TIWENVM1”, is 10:15:1. The secondary replica of the primary AG, “TIWENVM2”, is synchronous, and its hardened LSN is also 10:15:1. For the secondary AG, between the primary AG and the forwarder, synchronization mode is asynchronous, and the hardened LSN of the forwarder, “TIWENVM3”, is 10:12:1. The secondary replica of the secondary AG, “TIWENVM4”, is not yet synchronized and its hardened LSN is 10:10:1. Globally across the two AGs in the distributed AG, replica “TIWENVM4” has the smallest value of hardened LSN, truncation LSN on the global primary won’t go beyond this smallest value. In the event that “TIWENVM3” is lost and “TIWENVM4” becomes the new forwarder, it will be able to synchronize with the primary AG.



The reason for this is that when the transaction logs are backed up, only the logs that have been applied to all the replicas in the distributed AG (including the replicas in both AGs) will be truncated. The following table provides an example of how the transaction logs will be truncated in a distributed AG, using the test environment described at the beginning of this post.

This scenario can be easily demonstrated. The steps are as following:

  1. Record the current truncation_lsn and last hardened LSN of each replica.

  2. Modify the database. Here an INSERT query is executed 10 times on the “test” database.

  3. Verify that the last hardened LSN of each replica grows by the same number.

  4. Do a transaction logs back up on the “test” database on the global primary.

  5. Verify current truncation_lsn and last hardened LSN .

  6. Suspend data movement on the secondary replica on the secondary AG.

  7. Repeat 2-5.


The following screenshots record a complete repro of the scenario.


Step1 -
DMVs used in this step:

USE test

SELECT COUNT(*) AS '# of transaction logs' FROM fn_dblog(null, null)

SELECT database_id,
group_id,
replica_id,
is_local,
is_primary_replica,
truncation_lsn,
last_hardened_lsn
FROM sys.dm_hadr_database_replica_states
WHERE database_id=6 AND is_local=1

SELECT replica_id, replica_server_name
FROM sys.availability_replicas
WHERE replica_id=
(SELECT replica_id FROM sys.dm_hadr_database_replica_states WHERE database_id=6 AND is_local=1)

SELECT COUNT(*) AS '# of entries in testt1 table' FROM testt1

Results from the four replicas :

Primary replica on primary AG (global primary):



Secondary replica on primary AG:



Primary replica on secondary AG (forwarder):



Secondary replica on secondary AG:



If all the replicas are synchronized, all the replicas should have the same number of transaction logs as well as the same truncation_lsn as in the test environment shown in the screenshots above.
Step 2 -
Execute an INSERT clause 10 times.

INSERT INTO testt1 (NAME, ID) VALUES ('John Smith', 1)
GO

Step 3 -
Primary replica on primary AG (global primary):



Secondary replica on primary AG:



Primary replica on secondary AG (forwarder):



Secondary replica on secondary AG:



The size of transaction logs grows due to the INSERT executions. The increase of entries in the ‘test’ database also reflects that 10 rows are inserted into the table.

Step 4 -
Perform a transaction log backup on the global primary.




Step 5 -
Primary replica on primary AG (global primary):



Secondary replica on primary AG:



Primary replica on secondary AG (forwarder):



Secondary replica on secondary AG:



Truncation_lsn of each replica should grow to the current lsn, and the number of transaction logs should shrink by the same size as the t-logs have been truncated.


Step 6 -
Suspend data movement of ‘test’ database on the secondary replica on the secondary AG.




Step 7 -
After repeating step 2 and 3, we can see that except for the secondary replica on the secondary AG (TIWENVM4), the ‘test’ database on all other three replicas are modified again and another 10 entries are inserted into the table. The database on secondary replica on the secondary AG is not updated because the data movement has been suspended.

Primary replica on primary AG (global primary):



Secondary replica on primary AG:



Primary replica on secondary AG (forwarder):



Secondary replica on secondary AG:



The results from repeating step 4 and 5 are shown below.

Primary replica on primary AG (global primary):



Secondary replica on primary AG:



Primary replica on secondary AG (forwarder):



Secondary replica on secondary AG:



Note that the newly generated transaction logs were truncated on the secondary replica on the primary AG, but the truncation_lsn of the primary replica on the primary didn’t change after 10 new rows were inserted into the database and executing transaction logs back up. As mentioned earlier, this is because the secondary replica on the secondary AG of the distributed AG (TIWENVM4) is not yet synchronized and thus has not successfully applied the new transaction logs generated by the INSERT queries.

The global primary of a distributed AG only truncates logs to the least LSN among all the replicas in the distributed AG. This logic guarantees that there’ll be no data loss when the forwarder got lost even when the secondary replica on the secondary AG has not fully synchronized with the forwarder, as long as the global primary is in a healthy state and can communicate with the secondary replica on the secondary AG properly.

To simulate the scenario mentioned above, we shut down the network of the primary replica on the secondary AG (TIWENVM3) so that it becomes unavailable before we resume the data movement on the secondary replica on the secondary AG (TIWENVM4).



After the data movement of ‘test’ database on TIWENVM4 is resumed, the secondary AG (TIWENAG2) is now in a resolving state because the current primary replica on TIWENAG2, TIWENVM3, fails to be connected. To fix this issue, a failover needs to be performed. Under the scenario when in the secondary AG of a distributed AG, the forwarder is not available, the only failover option to the secondary replica of the secondary AG is FORCE_FAILOVER_ALLOW_DATA_LOSS .

ALTER AVAILABILITY GROUP TIWENAG2 FORCE_FAILOVER_ALLOW_DATA_LOSS

After performing failover with FORCE_FAILOVER_ALLOW_DATA_LOSS on the secondary replica on the secondary AG (TIWENVM4), the database is synced even though the previous forwarder is currently unavailable, as the global primary keeps track of the unsynchronized part of transaction logs of the secondary replica on the secondary AG.



In this scenario, though the only failover option is FORCE_FAILOVER_ALLOW_DATA_LOSS , there’s no data loss during the failover.

One thing worth notice is that after FORCE_FAILOVER_ALLOW_DATA_LOSS and the previous primary replica (in this case, TIWENVM3) is brought back, data movement will not resume automatically and needs to be resumed manually. This behavior is by design and not limited to the distributed AG scenario but applies whenever failover with FORCE_FAILOVER_ALLOW_DATA_LOSS is performed. This is because there might be difference and even conflicts between the previous primary replica and the new primary replica, and user needs to manually choose which version to keep.



After resuming data movement on TIWENVM3, all replicas on the distributed AG are synchronized and the transaction logs get truncated to the same point.

Primary replica on primary AG (global primary):



Secondary replica on primary AG:



(New) Secondary replica on secondary AG (former forwarder):



(New) Primary replica on secondary AG (new forwarder):



It needs to be clarified that though under this scenario, FORCE_FAILOVER_ALLOW_DATA_LOSS in the secondary AG doesn’t cause data loss, it’s not guaranteed that there’ll be no data loss when using this option to perform failover in a distributed AG. For example, if the primary AG is lost, there might be data loss when a force failover is performed in the secondary AG. This behavior is expected, and the cases that might cause data loss are not limited to this example.