Tatsuo Ishii <t-ishii@sra.co.jp> writes:
> Can someone tell me why we need sync() here?
> ?? I thought WAL files are synced by pg_fsync() (if needed).
They are. But to write a checkpoint record --- which implies that the
WAL records before it need no longer be replayed --- we have to ensure
that all the changes-so-far in the regular database files are written
down to disk. That is what we need sync() for.
regards, tom lane