ASYNC_IO_COMPLETION Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: BACKUPIO and BACKUPBUFFERRelated pillar: Storage & Capacity
⚡ASYNC_IO_COMPLETION is SQL Server waiting for large background I/O that does not go through the buffer pool, most often a backup reading data files, a checkpoint, or file creation. It is expected during backup windows and says little on its own. Run the check to line it up with your backups and see which files are slow.

Microsoft describes it as a task waiting for asynchronous non-data I/Os to finish, with log shipping, database mirroring and some bulk import operations as its examples. It is general-purpose asynchronous I/O that does not use the buffer pool, plus checkpoints; its sources include the start-of-backup checkpoint, reading the data files during a backup, database file creation and regular checkpoints. The two descriptions differ in emphasis, but both put it outside ordinary page reads, which are PAGEIOLATCH_* waits.


Is It a Problem?

It is expected in volume during backup and maintenance windows. One important detail: during a data backup, one of these waits lasts almost the whole backup, so a single long backup can make the average wait look alarming. Read the total next to your backup schedule before reading anything into it.

It is worth a look when it is high outside those windows, when backup durations keep growing, or when checkpoint writes compete with the workload for the same storage. Judge it over an interval rather than the cumulative totals: the baseline to monitor is backup duration for the same database over time.


Common Causes

  • Backups reading data files, stretching when the source storage or the backup target slows down.
  • Checkpoints flushing a lot of dirty pages after large modifications.
  • Creating database files, restores and other bulk file work.
  • Maintenance I/O and the user workload sharing the same storage path.

The Check To Run

Rank it against everything else with Get Wait Statistics. Then line it up with recent backups from msdb, since backup runs are the most common source:

SELECT TOP (20)
    database_name,
    type,
    backup_start_date,
    DATEDIFF(SECOND, backup_start_date, backup_finish_date) AS duration_s,
    CAST(backup_size / 1048576.0 AS DECIMAL(12, 1)) AS backup_mb
FROM msdb.dbo.backupset
ORDER BY backup_start_date DESC;

If the timings line up, judge the backups by their duration trend. To see whether the data files are slow, read the stalls per file with sys.dm_io_virtual_file_stats; these are cumulative since restart, so compare two readings:

SELECT
    DB_NAME(vfs.database_id) AS database_name,
    mf.physical_name,
    vfs.num_of_reads,
    vfs.io_stall_read_ms,
    CAST(vfs.io_stall_read_ms * 1.0 / NULLIF(vfs.num_of_reads, 0) AS DECIMAL(12, 2)) AS avg_read_ms,
    vfs.num_of_writes,
    vfs.io_stall_write_ms,
    CAST(vfs.io_stall_write_ms * 1.0 / NULLIF(vfs.num_of_writes, 0) AS DECIMAL(12, 2)) AS avg_write_ms
FROM sys.dm_io_virtual_file_stats(NULL, NULL) AS vfs
JOIN sys.master_files AS mf
    ON mf.database_id = vfs.database_id AND mf.file_id = vfs.file_id
ORDER BY vfs.io_stall_read_ms + vfs.io_stall_write_ms DESC;

Get Database IO Usage does the same with more detail. The file stats query needs VIEW SERVER STATE.


What To Do

  1. If it maps onto backup and maintenance windows, judge those jobs by duration rather than by the wait total.
  2. Move heavy maintenance away from peak hours, and use backup compression, which writes fewer bytes at the cost of CPU.
  3. If checkpoint bursts are the driver, indirect checkpoints (TARGET_RECOVERY_TIME, the default for new databases from SQL Server 2016) spread writes more evenly.
  4. If the data files show high read or write stalls outside backup windows, that is a storage conversation, with the per-file numbers as evidence.

The IO Family

These are I/O waits outside the page latch families: bulk file operations, file growth, backups and throttling. The main page is IO_COMPLETION; for reads and writes of data pages, see PAGEIOLATCH_SH.

  • IO_COMPLETIONSynchronous I/O. Waiting for I/O to finish, generally I/O that is not for data pages.The main page for this family
  • ASYNC_IO_COMPLETIONAsynchronous I/O. Bulk file work such as backups reading data files and checkpoints.Worth investigating. This page.
  • WRITE_COMPLETIONWrites. A write operation in progress.Worth a look when it climbs
  • FGCB_ADD_REMOVEFile growth. A latch class rather than a wait type, taken for file add, drop, grow and shrink.Worth investigating
  • IO_QUEUE_LIMITI/O throttle. Documented as internal use only; an I/O governance limit.Worth investigating
  • BAD_PAGE_PROCESSSuspect pages. The suspect page logger pacing itself; a corruption signal when present.Worth a look when it climbs
  • DISKIO_SUSPENDSnapshot backup. Waiting to access a file while an external backup is active.Worth a look when it climbs
  • REPLICA_WRITESSnapshot writes. Page writes to database snapshots or DBCC replicas.Worth a look when it climbs
  • FCB_REPLICA_READ / WRITESnapshot file sync. Synchronised reads from, and page pushes into, a snapshot sparse file.Usually noise
  • IMPPROV_IOWAITBulk load I/O. Waiting for a bulk load I/O to finish.Worth a look when it climbs
  • ASYNC_DISKPOOL_LOCKFile creation. Synchronising parallel threads that create or initialise a file.Worth a look when it climbs

Where To Go Next

If ASYNC_IO_COMPLETION is sitting near the top of your wait stats, these are the next places to look.

Comments

Leave a Reply

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