WRITE_COMPLETION Wait Type in SQL Server

WRITE_COMPLETION appears when a thread waits for a synchronous file write to finish. Ordinary dirty-page flushing goes through checkpoint and the lazy writer (showing up as other waits), so WRITE_COMPLETION covers the special cases: writes to database snapshot files, certain metadata writes, and other file operations the engine performs synchronously.

The database snapshot angle is the one that catches people. Every write to a snapshotted database first copies the old page into the snapshot’s sparse file, and DBCC CHECKDB creates a hidden internal snapshot, so integrity checks against a busy database can generate this wait without any visible snapshot existing.

Is It a Problem?

A small baseline is normal. It becomes worth attention when it rises into the top waits, and the timing usually gives the cause away: overlapping with DBCC CHECKDB means the internal snapshot is working hard on slow storage; constant presence on a system with user-created snapshots means the copy-on-write overhead is being felt.

Common Causes

  • DBCC CHECKDB’s internal snapshot absorbing copy-on-write activity during checks on a busy database.
  • User-created database snapshots on write-heavy databases, each write paying the sparse-file copy first.
  • Slow storage under the snapshot sparse files, which by default land on the same volume as the data files.
  • Other synchronous write paths during file-level operations.

What To Do

  1. Check the timing against DBCC CHECKDB runs and snapshot usage before anything else.
  2. If integrity checks drive it, schedule them off-peak, or run them against a restored copy on another server, which also validates your backups.
  3. If user snapshots drive it, review how many exist, how long they live, and what storage their sparse files sit on; drop stale ones.
  4. Measure the underlying volumes with sys.dm_io_virtual_file_stats to rule slow storage in or out.

How To See It

Rank it with Get-WaitStatistics. If WRITE_COMPLETION is high, map it against write-heavy jobs and storage metrics in the same time window.


Part of the SQL Server Wait Types Library.
Related deep dive: IO_COMPLETION.

Comments

Leave a Reply

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