SQL Server 2016 Always On – Secondary Server Redo Thread Blocked Issue

sql-server-2016

I need help for an always-on issue after upgrading to 2016 from 2014. Redo thread is causing blocking for all the select query on the secondary replica. all long running select queries are getting blocked by redo thread for a specific database. All DBs are already in sync. redo thread is getting blocked once I am running SQL job to fetch the data from secondary database.. redo queue size is also 0 and DB also synchronized before running the job. read routing URL also configured. Has anyone faced such a scenario? Please help with this.

I have tried multiple things to rid of deadlock issue and enabled the Is_Read_Commited_Snapshot option as well but still, that REDO thread ( DB sync) is blocked.

Best Answer

As per my understanding, this issue could be due to the multi-threading model or parallelism.

Until SQL Server 2016, the transaction log redo was handled by single redo thread for each database, this model is called as serial redo.

Starting from SQL Server 2016, the default redo model is parallel redo. It provides multiple threads for transactions and additional worker threads for dirty page flush IO operations.

While working with the concurrent workload, DIRTY_PAGE_TABLE_LOCK waits are generated frequently by the worker thread, and at the same time, query threads will try to access the tables, this will cause the performance issues on both SELECT query and redo operations.

This issue was fixed on the latest Cummulative Update - https://support.microsoft.com/en-in/help/4135048/cumulative-update-1-for-sql-server-2016-sp2

As a workaround, you can disable the parallel redo model and enable the serial redo by enabling the trace flag 3459.

I hope this helps! Thank you.