lowAlways On

HADR_WORK_QUEUE Wait Type Explained

HADR_WORK_QUEUE is a benign SQL Server wait type from Always On availability groups. Learn why it's normal, how to filter it from wait stats, and diagnostic queries.

Quick Answer

HADR_WORK_QUEUE is a benign wait type that occurs when Always On availability group background worker threads are idle and waiting for new tasks. This wait indicates healthy Always On operation and should be filtered from wait statistics analysis since it represents expected idle time, not a performance bottleneck.

Root Cause Analysis

HADR_WORK_QUEUE waits occur within the Always On availability group subsystem when dedicated background worker threads complete their current tasks and enter a wait state for new work assignments. These workers handle critical Always On operations including log transport, redo operations, and metadata synchronization between replicas.

The Always On thread pool maintains a pool of pre-allocated worker threads to handle availability group workload efficiently. When these workers finish processing log blocks, metadata updates, or health checks, they signal completion and wait on the HADR_WORK_QUEUE for the next assignment rather than terminating. This design prevents the overhead of constantly creating and destroying threads.

SQL Server 2012 introduced this wait type with Always On availability groups. The behavior remains consistent through SQL Server 2022, though the underlying efficiency of the worker thread management improved in SQL Server 2016 with better NUMA awareness and in SQL Server 2019 with enhanced log transport algorithms.

The wait accumulates during normal operations when the Always On workload is light relative to the available worker capacity. High HADR_WORK_QUEUE wait times typically indicate that your availability groups are healthy and not under stress, which is the desired state.

AutoDBA checks Always On availability group health monitoring and intelligent benign wait filtering across your entire SQL Server instance in 60 seconds. Download the free diagnostic script and see what else needs attention.

Diagnostic Queries

-- Verify HADR_WORK_QUEUE is present and not indicating problems
SELECT 
    wait_type,
    waiting_tasks_count,
    wait_time_ms,
    max_wait_time_ms,
    signal_wait_time_ms,
    wait_time_ms / NULLIF(waiting_tasks_count, 0) AS avg_wait_ms
FROM sys.dm_os_wait_stats 
WHERE wait_type = 'HADR_WORK_QUEUE'
    AND waiting_tasks_count > 0;

-- Wait stats excluding benign waits including HADR_WORK_QUEUE
SELECT TOP 20
    wait_type,
    wait_time_ms / 1000.0 AS wait_time_sec,
    waiting_tasks_count,
    wait_time_ms / NULLIF(waiting_tasks_count, 0) AS avg_wait_ms,
    (wait_time_ms * 100.0) / SUM(wait_time_ms) OVER() AS percent_total
FROM sys.dm_os_wait_stats
WHERE wait_type NOT IN (
    'HADR_WORK_QUEUE', 'CLR_AUTO_EVENT', 'CLR_MANUAL_EVENT', 
    'REQUEST_FOR_DEADLOCK_SEARCH', 'BACKUPTHREAD', 'CHECKPOINT_QUEUE',
    'SP_SERVER_DIAGNOSTICS_SLEEP', 'SQLTRACE_INCREMENTAL_FLUSH_SLEEP'
)
    AND wait_time_ms > 1000
ORDER BY wait_time_ms DESC;

Prevention

No prevention is necessary for HADR_WORK_QUEUE waits since they indicate normal Always On availability group operation. Attempting to eliminate these waits would actually indicate a problem with your Always On configuration or excessive workload that prevents worker threads from entering their normal idle state.

Modern monitoring solutions like AutoDBA automatically filter benign waits including HADR_WORK_QUEUE, allowing DBAs to focus on waits that actually impact performance. Manual wait analysis should always exclude these background waits to avoid misinterpreting healthy system behavior as performance problems.

Need hands-on help?

Dealing with persistent hadr_work_queue issues across your environment? Samix Technology provides hands-on SQL Server performance consulting with 15+ years of production DBA experience.

Related Pages