In a previous post I talked about how we can use T-SQL Snapshot Backups to take application consistent snapshots of secondary replica databases. This gets around having to freeze IO on the primary database and I finished the post by saying…
But there we have it, a way to take application consistent snapshots of databases without having to worry about the effects of a stun on our applications.
Hmmmm…but does stunninng/freezing/quiescing IO on a secondary really have no effect on transactions on the primary?
Let’s have a look…
Firstly, kicking off a hammerdb workload against my database…using Anthony Nocentino’s containerised setup: –
https://github.com/nocentino/hammerdb
We can see the queries running with sp_whoisactive: –

All good…queries executing as normal. Now, let’s go and suspend the IO on the secondary database: –
ALTER SERVER CONFIGURATION SET SUSPEND_FOR_SNAPSHOT_BACKUP = ON (GROUP = (tpcc), MODE = COPY_ONLY);
And if we check the queries again: –

Ah ha. Ok, transactions are waiting on HADR_SYNC_COMMIT.
Which makes sense right? IO is frozen on the secondary, we’re not getting an acknowledgement back that transactions have been committed, so the transactions on the primary have to wait.
So my statement in my previous post wasn’t entirely correct. True yes, we don’t have to worry about the stun on the primary database but there are knock on effects of stunning IO on the primary…so we still need to factor that into consideration when taking T-SQL Snapshot Backups on a secondary node.
Or switch the availability group into asynchronous replication (joke!)
Thanks for reading!