Flush operations and durability
Overview
A successful commit and a durable commit are not identical under every configuration. Buffers can reside in database memory, operating-system cache or device cache. Synchronization operations request persistence according to the filesystem and hardware contract. WAL ordering and truthful flush behavior matter. PostgreSQL synchronous_commit controls commit acknowledgment; turning it off can lose recent acknowledged transactions in a crash. Disabling fsync is a different and much riskier choice.
First example
PRAGMA synchronous=FULL;PRAGMA synchronous;Observed SQLite result (rows in JSON):
[ [ 2 ]]How it works
SQLite synchronous FULL corresponds to 2, EXTRA to 3 and NORMAL to 1; these are configuration levels, not measurements of flushes. In WAL mode FULL requests a WAL sync on each commit, whereas NORMAL may lose recent commits after power loss while retaining consistency under documented assumptions. In-memory examples only verify settings. The host experiment explicitly sets FULL on each write connection. A process exit is not a power failure; it leaves the OS and device powered.
Practical example
PRAGMA synchronous=EXTRA;PRAGMA synchronous;Observed SQLite result (rows in JSON):
[ [ 3 ]]Practice and mistakes
Practice: compare the documented acknowledgment guarantees of FULL and NORMAL in WAL mode. Hint 1: distinguish application process failure from power loss. Hint 2: ask whether a flush is required at commit. Never weaken durability on a production database for this exercise.
PostgreSQL 17 example — NOT RUN
SHOW fsync;SHOW synchronous_commit;SHOW full_page_writes;Expected result, not executed: "Read settings only; no durability change or physical flush measurement."