Don't use O_DIRECT when writing WAL files if archiving or streaming is
Heikki Linnakangas <heikki.linnakangas@iki.fi>
Don't use O_DIRECT when writing WAL files if archiving or streaming is enabled. Bypassing the kernel cache is counter-productive in that case, because the archiver/walsender process will read from the WAL file soon after it's written, and if it's not cached the read will cause a physical read, eating I/O bandwidth available on the WAL drive. Also, walreceiver process does unaligned writes, so disable O_DIRECT in walreceiver process for that reason too.
Files
| Path | Change | +/− |
|---|---|---|
| src/backend/access/transam/xlog.c | modified | +24 −8 |
| src/backend/replication/walreceiver.c | modified | +14 −8 |
| src/include/access/xlogdefs.h | modified | +6 −9 |
| src/include/replication/walreceiver.h | modified | +3 −1 |