PREEMPTIVE_OS_FLUSHFILEBUFFERS Wait Type in SQL Server

⏳Part of the SQL Server Wait Types Library, every wait type explained.Related deep dive: WRITELOG Wait TypeRelated pillar: Performance & Troubleshooting

Is It a Problem?

On Linux, its dominance is expected; on Windows, modest amounts are noise. Our SQL Server 2025 lab, on Windows, had about 1,500 waits totalling 7.6 seconds in a day. Get Wait Statistics does not filter it out, so if it ranks, you will see it.


What It Means

Microsoft lists it as internal use only. It is the Windows FlushFileBuffers function, which forces buffered writes for a file to durable storage. On Linux, KB 4131496 explains why it matters there: SQL Server 2017 CU6 added a forced flush mechanism for checkpoint and transaction log writes to protect against data loss on storage with volatile caches. The flush is translated into fdatasync on Linux, and this wait shows as the top wait on 2017 CU6 and later with the default settings.


When It Does Matter

On Linux, when the cost of the forced flush matters to you. The same KB says that on storage that guarantees writes are durable, the flush can be turned off with trace flag 3979 plus the writethrough and alternatewritethrough settings in mssql.conf; it is a durability decision, so make it with the storage vendor’s guarantee in hand. On either platform, a flush is only as fast as the storage honouring it, so check write latency:

SELECT
    DB_NAME(vfs.database_id) AS database_name,
    mf.type_desc,
    mf.physical_name,
    vfs.num_of_reads,
    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,
    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;

The baseline to monitor is per-file write latency against its own history. The query needs VIEW SERVER STATE.


The PREEMPTIVE_OS File Waits

Each of these is SQL Server calling a Windows file API and waiting for it to return, so the time is spent in the operating system and the storage underneath it. If one is near the top of your waits, read it next to the waits that usually matter.

  • PREEMPTIVE_OS_WRITEFILEGATHERZeroing file space. Writing zeros into new file space when a file is created or grows without instant file initialization.Worth investigating
  • PREEMPTIVE_OS_CREATEFILEOpening files. The Windows CreateFile call, used to open existing files as well as create new ones.Worth a look when it climbs
  • PREEMPTIVE_OS_FLUSHFILEBUFFERSFlushing to disk. Forcing buffered writes for a file down to durable storage.Worth a look when it climbs. This page.
  • PREEMPTIVE_OS_FILEOPSOther file calls. A catch-all for Windows file functions without a wait type of their own.Worth a look when it climbs
  • PREEMPTIVE_OS_GETDISKFREESPACEFree space checks. Asking Windows how much space a volume has, often from monitoring queries.Usually noise
  • File Operation waitsThe rest of the file APIs. The smaller file calls covered together on one page.Worth a look when it climbs

Where To Go Next

PREEMPTIVE_OS_FLUSHFILEBUFFERS is expected on Linux. 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 *