r/SQLServer • u/Kenn_35edy • May 07 '26
Question data synchronization in sql server always on availability groups
Hi As title suggest i was looking for how data gets syncgronized in sql server always on setsup.I mean what happens internally i know i can google but different weistes says different things . Even microsof doenot have one properly so if any one can provide link it would get great
0
Upvotes
View all comments
Show parent comment
1
u/MasterChiefmas May 07 '26
At a basic level, it's similar to log shipping, but it's at the transaction level. Every single transaction is shipped immediately to the replicas. In synchronous mode, a transaction isn't considered complete on the primary until the replica partners have acknowledged that they have hardened it to their databases first. Replicas acknowledging are part of the transaction. If the replicas fail to write/ack/whatever, the transaction is not committed on the primary, it fails and rolls back. In async mode, the primary doesn't wait for acknowledgement from the replicas, as soon as it's hardened locally, it's marked complete, so similar to a standalone server.That means your asyncs can get out of sync with the primary, and consistency is not guarnteed between the replicas and the primary.
Asynchronous mode is more close to how log shipping generally works, in that the primary doesn't care about the state of the replicas. In synchronous mode, the replicas hardening are part of the transaction, and a transaction isn't closed until replicas indicated they are complete. In both cases though, as I said, this happens at the transaction level- so imagine if you shipped a log for every single transaction as soon as it happens.
So for synchronous, it's roughy:
For Async:
I think in async the replicas still send an ack back to the primary, but the primary doesn't wait for the ack, unlike the synchronous mode. In async, the primary doesn't care if the replicas ack. So it's much closer to log shipping, just the ship happens immediately and for every single transaction- transactions are not queued up and sent in batches like log shipping.
Put more simply, in synchronous mode, the primary isn't done until the replicas say they are done first. If anyone fails at any point, the transaction should roll back on everyone. Replicas become just as important as the primary, and the primary always waits for the replicas.