The official documentation says that synchronous-commit with automatic failover will not lose data. But I'm still confused about how this is guaranteed. Actually I'm confused how the replication, commit, ack of secondary and reply to client located in the workflow.
Is it possible that some synchronous-commit ack but the master crashes before it receives all acks? In this case, some of the secondaries are in the lead of the transaction log and one of them become next master which with the uncommitted transaction committed.
Or maybe the always-on do 2PC, the master send commit signal to all secondaries and secondaries commit after receive the signal? Then will there be a condition that that master crashes after sending the commit signal but before it replies to the client, then we still have an uncommitted transaction committed.
I've setup the availability group myself, but I'm not sure how to confirm my suspicions because SQL Server is not open sourced.