๐ŸŒ
PostgreSQL Wiki
wiki.postgresql.org โ€บ wiki โ€บ Fsync_Errors
Fsync Errors - PostgreSQL wiki
July 5, 2023 - It has sometimes been referred to as "fsyncgate 2018". ... As of this PostgreSQL 12 commit, PostgreSQL will now PANIC on fsync() failure. It was backpatched to PostgreSQL 11, 10, 9.6, 9.5 and 9.4.
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
there were several data loss inducing bugs in postgres with fsync/close | Hacker News
April 15, 2023 - We can blame Postgres for not handling this case properly, but I think the design of fsync bears just as much blame here. A write completion callback (as suggested upthread) would be a much more sensible and intuitive way to pass write errors back to the database.
Discussions

PostgreSQL used fsync incorrectly for 20 years
I patched my own systems (wrap the calls in a loop as per standard practice) and then proceeded to run literally hundreds of thousands of PostgreSQL instances on NFS for many more years with no problems ยท The patch was eventually integrated it seems but I never found out why because I lost ... More on news.ycombinator.com
๐ŸŒ news.ycombinator.com
307
676
February 14, 2019
Fsyncgate: errors on fsync are unrecovarable
Is any bug a "gate" now? Please... More on reddit.com
๐ŸŒ r/programming
35
139
July 21, 2019
Does turning off fsync in PostgreSQL can corrupt all the database or only the specific table I'm working with - Stack Overflow
I'm working with PostgreSQL and I read a lot about the unrecommended option of disabling fsync (fsync = off). However, it was not clear to me if disabling the fsync option may corrupt all the datab... More on stackoverflow.com
๐ŸŒ stackoverflow.com
PostgreSQL's fsync() surprise
Why would open() followed by fsync() in one process be expected to show errors that were encountered in another process that had written the same file? More on reddit.com
๐ŸŒ r/programming
46
153
April 24, 2018
๐ŸŒ
PostgreSQL Wiki
wiki.postgresql.org โ€บ wiki โ€บ May_2015_Fsync_Permissions_Bug
May 2015 Fsync Permissions Bug - PostgreSQL wiki
On May 22, 2015, the PostgreSQL project released a set of updates to all supported versions of PostgreSQL. One of the fixes included in this batch of updates forced fsyncing of all PostgreSQL files on a restart after a crash.
๐ŸŒ
Hacker News
news.ycombinator.com โ€บ item
PostgreSQL used fsync incorrectly for 20 years | Hacker News
February 14, 2019 - I patched my own systems (wrap the calls in a loop as per standard practice) and then proceeded to run literally hundreds of thousands of PostgreSQL instances on NFS for many more years with no problems ยท The patch was eventually integrated it seems but I never found out why because I lost ...
๐ŸŒ
Percona
percona.com โ€บ home โ€บ postgresql fsync failure fixed โ€“ minor versions released feb 14, 2019
PostgreSQL fsync Failure Fixed โ€“ Minor Versions Released Feb 14, 2019
February 10, 2024 - The reason is that writes to storage from the page cache are completely managed by the kernel, and not by PostgreSQL. This could still be fine if the next fsync retries flushing of the dirty page. But, in reality, the data is discarded from the page cache upon an error with fsync.
๐ŸŒ
Mydbanotebook
mydbanotebook.org โ€บ posts โ€บ the-fsync-issue-and-postgres
The fsync issue and Postgres | My DBA Notebook
Postgres expected the OS to retry flushing data from the cache to disk if an error occurred during the previous fsync call.
๐ŸŒ
LWN.net
lwn.net โ€บ Articles โ€บ 752063
PostgreSQL's fsync() surprise [LWN.net]
April 18, 2018 - Craig Ringer first reported the problem to the pgsql-hackers mailing list at the end of March. In short, PostgreSQL assumes that a successful call to fsync() indicates that all data written since the last successful call made it safely to persistent storage. But that is not what the kernel ...
๐ŸŒ
Reddit
reddit.com โ€บ r/programming โ€บ fsyncgate: errors on fsync are unrecovarable
r/programming on Reddit: Fsyncgate: errors on fsync are unrecovarable
July 21, 2019 - because the disk was idle), and something went wrong, that error would be lost; that bug has since been fixed, in Linux 4.13. Once that was fixed, the main remaining issue that affected PostgreSQL (and is also relevant for a few other programs, like dpkg, which are trying to allow for write failures in some other program) is that its "open, write, close, open, fsync, close" strategy failed because fsync() only reported errors that occurred since the file was opened (which IMO is a reasonable API, but some of the PostgreSQL developers disagreed).
๐ŸŒ
Postgres Professional
postgrespro.com โ€บ list โ€บ thread-id โ€บ 2385065
Thread: Postgres, fsync, and OSs (specifically linux) : Postgres Professional
Thirdly I'll try to sum up what postgres needs to change. == Current Situation == The fundamental problem is that postgres assumed that any IO error would be reported at fsync time, and that the error would be reported until resolved.
Find elsewhere
๐ŸŒ
Postgres Professional
postgrespro.com โ€บ list โ€บ thread-id โ€บ 2379543
Thread: PostgreSQL's handling of fsync() errors is unsafe and risks data loss at least on XFS : Postgres Professional
Some time ago I ran into an issue where a user encountered data corruption after a storage error. PostgreSQL played a part in that corruption by allowing checkpoint what should've been a fatal error. TL;DR: Pg should PANIC on fsync() EIO return. Retrying fsync() is not OK at least on Linux.
๐ŸŒ
Danluu
danluu.com โ€บ fsyncgate
Fsyncgate: errors on fsync are unrecovarable
Some time ago I ran into an issue where a user encountered data corruption after a storage error. PostgreSQL played a part in that corruption by allowing checkpoint what should've been a fatal error. TL;DR: Pg should PANIC on fsync() EIO return. Retrying fsync() is not OK at least on Linux.
๐ŸŒ
DBI Services
dbi-services.com โ€บ accueil โ€บ postgres, the fsync() issue, and โ€˜pgioโ€™ (the slob method for postgresql)
Postgres, the fsync() issue, and 'pgio' (the SLOB method for PostgreSQL)
May 24, 2018 - This is ok when everything goes well because the writes since the last checkpoints are protected by the Write Ahead Logging, where fsync() occurs for each writes at commit (if you didnโ€™t change the default parameters for WAL). But when a problem occurs, such as power outage, some writes may be lost, or partially lost, and thatโ€™s not easy to detect at checkpoint time with fsync().
๐ŸŒ
Medium
gauravsarma1992.medium.com โ€บ how-safe-is-your-fsync-792916545101
How safe is your fsync? | by Gaurav Sarma | Medium
August 31, 2025 - This means that when PG retries the checkpointing process, the fsync operation returns back a success response. This results in an error where the checkpointing returns back a success response without actually writing the data to the disk, thus ...
๐ŸŒ
PostgreSQL
postgresqlco.nf โ€บ en โ€บ doc โ€บ param โ€บ fsync
PostgreSQL Documentation: fsync parameter
While turning off fsync is often a performance benefit, this can result in unrecoverable data corruption in the event of a power failure or system crash. Thus it is only advisable to turn off fsync if you can easily recreate your entire database ...
๐ŸŒ
PostgreSQL
postgresql.org โ€บ message-id โ€บ CAMsr+YHh+5Oq4xziwwoEfhoTZgr07vdGG+hu=1adXx59aTeaoQ@mail.gmail.com
PostgreSQL: PostgreSQL's handling of fsync() errors is unsafe and risks data loss at least on XFS
March 28, 2018 - Some time ago I ran into an issue where a user encountered data corruption after a storage error. PostgreSQL played a part in that corruption by allowing checkpoint what should've been a fatal error. TL;DR: Pg should PANIC on fsync() EIO return. Retrying fsync() is not OK at least on Linux.
๐ŸŒ
PostgreSQL
postgresql.org โ€บ docs โ€บ 8.1 โ€บ runtime-config-wal.html
PostgreSQL: Documentation: 8.1: Write Ahead Log
January 1, 2012 - However, using fsync results in a performance penalty: when a transaction is committed, PostgreSQL must wait for the operating system to flush the write-ahead log to disk. When fsync is disabled, the operating system is allowed to do its best ...
๐ŸŒ
Reddit
reddit.com โ€บ r/programming โ€บ postgresql's fsync() surprise
r/programming on Reddit: PostgreSQL's fsync() surprise
April 24, 2018 - But then we retried the checkpoint, which retried the fsync(). The retry succeeded, because the prior fsync() cleared the AS_EIO bad page flag." More replies ... Because many things people assume to be safe would be broken otherwise. Take Andres's example of untaring a database backup and then running sync to make sure everything is persisted on disk. Maybe people, including the PostgreSQL team, need to change their expectations for what works when there are IO errors, but I also suspect that we need more convenient kernel APIs.
๐ŸŒ
PostgreSQL
postgresql.org โ€บ message-id โ€บ 20140211222906.2717.71884@wrigleys.postgresql.org
PostgreSQL: BUG #9190: Could not fsync file "pg_clog/0000": Bad file descriptor.
February 11, 2014 - Bug reference: 9190 Logged by: David Vitek Email address: dvitek(at)grammatech(dot)com PostgreSQL version: 9.2.4 Operating system: Windows 8 Description: We had a postgres panic a few weeks ago. Here is a relevant fragment of the postgres log: [2014-01-27 04:57:37 EST 3756] WARNING: pgstat wait timeout ... ... ... [2014-01-27 04:55:36 EST 5804] ERROR: could not access status of transaction 0 [2014-01-27 04:55:42 EST 5804] DETAIL: Could not fsync file "pg_clog/0000": Bad file descriptor.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 4187767 โ€บ postgresql-9-could-not-fsync-file-base-16386-invalid-argument
database - PostgreSQL 9: could not fsync file "base/16386": Invalid argument - Stack Overflow
I'm trying to test a small PostgreSQL setup, so I cobbled together a quick local install. However, when I'm trying to create my personal db with createdb, it chokes on errors like this (notably, it starts with base/16384 the first time, and increments each time I run it).