SQLite Forum

How to corrupt - windows
Login
Assuming that my pragmas are properly set so that sqlite calls FlushFileBuffers() at the appropriate times.

Does the Windows setting "Enable write caching on the device" specifically allow Windows to return from FlushFileBuffers() too soon? Here I'm assuming that cheap hardware didn't lie to Windows in the first place.

Postgres reliability documentation at https://www.postgresql.org/docs/13/wal-reliability.html says: 

On Windows, if wal_sync_method is open_datasync (the default), write caching can be disabled by unchecking My Computer\\Open\\disk drive\\Properties\\Hardware\\Properties\\Policies\\Enable write caching on the disk. **Alternatively, set wal_sync_method to fsync or fsync_writethrough, which prevent write caching.**

The **Alternatively** section implies that if even if write caching is enabled (at the OS level), calls to fsync (and presumably FlushFileBuffers) will send pending writes to the hardware.

I don't see anything in the FlushFileBuffers() documentation that says it is allowed to return early, but I'm no expert in that level of Windows i/o.