Search code examples
phpyiiapc

Why I randomly encounter this fatal error with apc (in Yii Framework)?


I sometimes run into

Fatal error: require() [<a href='function.require'>function.require</a>]: apc_fcntl_lock failed errno:6 in C:\web\yii\framework\web\CWebApplication.php on line 345

code context:

        else
            $controllerID.='/';
        $className=ucfirst($id).'Controller';
        $classFile=$basePath.DIRECTORY_SEPARATOR.$className.'.php';
        if(is_file($classFile))
        {
            if(!class_exists($className,false))
                require($classFile);  ////////////THIS IS LINE 345
            if(class_exists($className,false) && is_subclass_of($className,'CController'))
            {
                $id[0]=strtolower($id[0]);
                return array(
                    new $className($controllerID.$id,$owner===$this?null:$owner),
                    $this->parseActionParams($route),
                );
            }
            return null;
        }

Relative runtime environment:

OS:win2k3.
PHP Version 5.3.6 
Server API  CGI/FastCGI

apc:
Version 3.1.8-dev
APC Debugging   Disabled
MMAP Support    Disabled
Locking type    File Locks
Serialization Support   php
Revision    $Revision: 308812 $
Build Date  Mar 1 2011 13:31:44

What caused this error? How do I fix it?


Solution

  • This looks like an APC issue, which I also encounter from time to time. I can't tell you 100% what's going on, but, while developing you often change, move or overwrite files. APC then seems to loose the inode of the file which is used internally to handle to bytecode-caching.

    For me the only way to 'fix' the error is to restart the webserver.

    Does this also happen on production systems, where you don't change the sourcecode very often?