Sql-server – Why does the log file grow larger than data file for an availability group database on the secondary replica

availability-groupssql serversql-server-2016transaction-log

I've got a SQL Server 2016 AG set up with only two replicas (primary and secondary). Both synchronous, non-readable secondary, and backup the primary only.

Transaction Log backups occur on the primary replica via scheduled SQL Jobs that execute on both replicas every half hour. Full backups occur nightly. FULL recovery model.

The issue is over time the secondary replica log file eventually grows to be larger than the data file, while the primary remains fine. The only thing I do that helps is a manual failover, which seems to kick off the log backup jobs on the (now old) secondary replica since its readable again. Any tips on how to handle this?

Best Answer

Since the log file is only growing on the secondary replica, something is preventing transaction log truncation on that database (but not on the primary).

You'll need to check the value of log_reuse_wait_desc in sys.databases on the secondary replica to see why the transaction log isn't being cleared there.


Since log_reuse_wait_desc is currently showing "NOTHING" you should check on the health of the AG itself. Open up the AG dashboard (in SSMS, under "Always on High Availability" right-click the AG and choose "Show Dashboard). Check to see if there are any errors or warnings, and confirm that the secondary replica is listed and is healthy / synchronized.

Additional, check out the SQL Server error log on the secondary to see if there are any errors or warnings related to the AG or the database in question. This is a weird one!