NFS Cache

Jonatan Evald Buus jonatan.buus at
Mon Dec 22 19:36:59 UTC 2008

We are having problems with Record Based Log Shipping from our PostGreSQL
database server that appears to stem from NFS caching the files.
PostGreSQL are continously writing to its WAL files located in the pg_xlog
directory which is shared via NFS
Our program is in turn continously detecting the changes as described in
24.4.4 at and
copying a segment of the WAL file to the local harddisk.

The changes written by PostGreSQL however doesn't appear to be reflected
through the mapped NFS drive until at some later point in time (not sure how
long the delay is, but it appears to be 10+ seconds). The delay causes the
transferred WAL files to become corrupt.
Running the same program directly on the PostGreSQL machine provides the
expected result.

The following is the NFS configuration on both the Client and Server
sysctl -a |grep nfs
vfs.nfs.downdelayinitial: 12
vfs.nfs.downdelayinterval: 30
vfs.nfs.skip_wcc_data_onerr: 1
vfs.nfs.nfs3_jukebox_delay: 10
vfs.nfs.reconnects: 0
vfs.nfs.bufpackets: 4
vfs.nfs.realign_count: 0
vfs.nfs.realign_test: 0
vfs.nfs.defect: 0
vfs.nfs.iodmax: 20
vfs.nfs.iodmin: 0
vfs.nfs.iodmaxidle: 120
vfs.nfs.diskless_valid: 0
vfs.nfs.nfs_ip_paranoia: 1
vfs.nfs.nfs_directio_allow_mmap: 1
vfs.nfs.nfs_directio_enable: 1
vfs.nfs.clean_pages_on_close: 1
vfs.nfs.nfsv3_commit_on_close: 0
vfs.nfs.access_cache_timeout: 0
vfs.nfs4.access_cache_timeout: 0
vfs.nfsrv.nfs_privport: 0
vfs.nfsrv.commit_miss: 0
vfs.nfsrv.commit_blks: 0
vfs.nfsrv.async: 0
vfs.nfsrv.realign_count: 0
vfs.nfsrv.realign_test: 4069
vfs.nfsrv.gatherdelay_v3: 0
vfs.nfsrv.gatherdelay: 10000

Are there other ways of disabling the NFS' cache than using sysctl?
Preferably at mount time so caching is only disabled for the PostGreSQL
mount point.
Alternatively, how is NFS forced to use Direct IO?

Appreciate the input


More information about the freebsd-questions mailing list