NFS - PHP issue

We are facing a weird issue. We have NFS set up with 2 machines mounted with this in read-only mode. Whenever we upload an include file, suddenly we are getting 500 error in PHP. When we trace the code execution, we find that the error encountered is due to the include file not found issue. But physically the file is present in the disk and very much readable. When we unmount and mount it again, this error gets resolved. This issue comes randomly whenever we upload a file.

We are unable to get any clue. Any inputs would be greatly appreciated.

Thanks in advance.

Upvotes: 3

Views: 3771

Answers (1)

Drahkar
Drahkar

Reputation: 1671

This sounds like it could be a file lock issue. NFS can lock files being executed/accessed while they prevent others from accessing them. Implemented in bad fashions it can lead to a deadlock which results in the file being useless until the application accessing it is removed.

Here is some more information on File Locking: http://en.wikipedia.org/wiki/File_locking

I would recommend checking to see how your NFS is configured in regards to File Locking and address that against your needs for accessing it.

If it is read only, you don't really need to have file locking enabled as the primary benefits of File locking are to prevent two people from writing to a location at the same time or when someone is writing to a location, preventing someone from reading an outdated or not completely finished version of the data. As a read only data point this is not required in this situation.

Update:

To disable File Locking on Linux NFS, when you mount the NFS point, in the options you assign to it, add nolock.

For example if this was your /etc/fstab:

/dev/hda2   /   ext2    defaults    1 1
/dev/hdb1   /home   ext2    defaults    1 2
/dev/cdrom  /media/cdrom    auto    ro,noauto,user,exec 0 0
/dev/fd0    /media/floppy   auto    rw,noauto,user,sync 0 0
proc    /proc   proc    defaults    0 0
/dev/hda1   swap    swap    pri=42  0 0
nfssrv.server.com:/content  /opt/content  nfs  rw,bg,soft,actimeo=0,rsize=8192         0 0

You would change it to:

/dev/hda2   /   ext2    defaults    1 1
/dev/hdb1   /home   ext2    defaults    1 2
/dev/cdrom  /media/cdrom    auto    ro,noauto,user,exec 0 0
/dev/fd0    /media/floppy   auto    rw,noauto,user,sync 0 0
proc    /proc   proc    defaults    0 0
/dev/hda1   swap    swap    pri=42  0 0
nfssrv.server.com:/content  /opt/content  nfs  rw,bg,soft,actimeo=0,rsize=8192,nolock         0 0

Upvotes: 4

Related Questions