PWAIT_HADR_WORKITEM_COMPLETED Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: HADR_SYNC_COMMIT Wait TypeRelated pillar: High Availability

Is It a Problem?

Short appearances during Availability Group changes are the mechanism working. It is documented as an expected wait, for Microsoft support’s use. It is worth a look only when one thread sits in it for a long time, because then the operation behind it has stalled. Get Wait Statistics does not filter it out, so if it ranks, you will see it.


What It Means

It is an internal wait by a thread waiting for an async work task to complete. Microsoft does not say which operations hand their work to such a task, so read it against whatever Availability Group change was running when it rose.


When It Does Matter

When an AG command runs far longer than it normally does and one thread keeps building this wait, because the task it is waiting for has stalled. Before restarting anything, check the state of the databases and replicas involved:

SELECT
    ag.name AS ag_name,
    DB_NAME(drs.database_id) AS database_name,
    drs.is_local,
    drs.synchronization_state_desc,
    drs.database_state_desc
FROM sys.dm_hadr_database_replica_states AS drs
JOIN sys.availability_groups AS ag ON ag.group_id = drs.group_id
ORDER BY ag.name, database_name;

Read the error log and the cluster log for the same window. The baseline to monitor is how long your usual AG changes take; a command well past that is the signal. If it reproduces, check the build’s fix list before retrying. The query needs VIEW SERVER STATE.


The HADR Secondary Replica Waits

These are the Availability Group waits around redo on a secondary, readable secondaries in particular, and the asynchronous work tasks behind AG operations. For AG latency, start from the main page, HADR_SYNC_COMMIT.

  • HADR_SYNC_COMMITSynchronous commit. The primary waiting for a synchronous secondary to harden the log.The main page for this family
  • DIRTY_PAGE_TABLE_LOCKDirty page table. Redo and read queries on a readable secondary contending for the list of dirty pages.Worth investigating
  • DPT_ENTRY_LOCKDirty page entries. The same contention when redo and reads want the same pages.Worth a look when it climbs
  • REDO_THREAD_PENDING_WORKRedo idle. A redo thread on a secondary waiting to be told there is more log to redo.Usually noise
  • PWAIT_HADR_WORKITEM_COMPLETEDAG operations. Waiting for an asynchronous AG work task to complete.Worth a look when it climbs. This page.

Where To Go Next

PWAIT_HADR_WORKITEM_COMPLETED follows AG changes. If you are chasing a real problem, start with the waits that cost you time.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *