4

I ran into a bug similar to this one:

RHEL NFS client returns NULL bytes when reading a growing file

So my solution was to check for \0 Bytes and reread the file. Problem here is, that the wrong file, which includes the \0 Bytes, is cached on the system where the java application runs. So it takes quite a while to read the correct file contents.

When I do a sync && echo 2 > /proc/sys/vm/drop_caches it immediately reads the correct content.

I tried to add sync to the NFS mount options without a difference.

Is it possible to disable the file cache for a specific mount point? If so, how to do that?

alexus
  • 12,342
  • 27
  • 115
  • 173
robin.koch
  • 141
  • 1
  • 4
  • That content is not available to everyone. What did it tell you to do? And what did you do afterward? – Michael Hampton Jul 20 '15 at 15:40
  • I don't have a redhat account. So I don't know what their workaround is. I just added it because it contains a very good description of the problem. – robin.koch Jul 20 '15 at 16:06
  • I just want to disable cache to avoid reading external SD cards to fill the RAM and push away other cached data. – neverMind9 Mar 07 '19 at 14:01

1 Answers1

1

Resolution

This issue was discussed with Red Hat Engineering under Private Bug 702085, but was not able to be repaired within the RHEL 5 product lifecycle.

Red Hat Product Management have elected not to repair this issue within RHEL 6 for the following reasons:

  • Customer exposure to this issue is not significant.
  • This behaviour is documented on the Customer Portal along with workarounds.
  • This behaviour is much harder (takes longer) to reproduce in RHEL 6 compared to RHEL 5.
  • The NFS protocol does not guarantee cache coherence.

Workarounds:

  • Ensure one client cannot read a file while another client is accessing it by using file locks, such as flock in shell scripts, or fcntl() in C.
  • Open the file with O_DIRECT so that the page cache is avoided.
  • Do not read past the EOF.
  • For example, in Python use os.stat() to get the file size, os.open() to open the file and os.read() to read only up to the file size.
  • Avoid running tail -f on files residing on NFS mounts.
  • If using RHEL 5, the sync mount option will also avoid this issue. This will not work in RHEL6, as the nfs_readpage_sync() function was removed upstream in between RHEL 5 and RHEL 6, so that function does not exist in RHEL 6.
Cristian Ciupitu
  • 6,226
  • 2
  • 41
  • 55
alexus
  • 12,342
  • 27
  • 115
  • 173