Search code examples
phplinuxnfsstat

"stat failed" problems on NFS sharing


On production servers we have a mount point with NFS:

192.168.160.5:/var/www on /var/www type nfs (rw,sync,noatime,intr,soft,timeo=30,rsize=32768,wsize=32768,intr,soft,timeo=30,rsize=32768,wsize=32768,addr=192.168.160.5)

We have 2 machines that are mounted this way, but lately we are experiencing weird problems. For example, the following script:

clearstatcache();
if ( !file_exists($file_path) ) {
    return false;
}
//calc time
$mtime = filemtime($file_path);

Gives error:

filemtime() [function.filemtime]: stat failed for /var/www/XXX/954340789.2319_.html in /var/www/XXX.module on line 66.

I can't reproduce this error whenever I want, meaning it occurs randomly.

Any suggestion how to try to deal with the problem?

More information:

  • All servers are Debian 6.0.5 (Squeeze)
  • kernel 2.6.32-5-amd64
  • PHP 5.3.3-7+squeeze9

Solution

  • Of course... Linux kernel log can give you lot of information... :O

    cat /var/log/messages
    Jan 29 08:50:16 XXX kernel: : [21599205.989424] nfs: server 192.168.160.53 not responding, timed out
    Jan 29 08:50:16 XXX kernel: : [21599206.093387] nfs: server 192.168.160.53 not responding, timed out
    Jan 29 08:50:17 XXX kernel: : [21599206.461316] nfs: server 192.168.160.53 not responding, timed out
    

    I'll not delete this question, it might help someone else....