@ZEAL Blog·厉
We stand alone,


Posted by zeal on 2013-12-02 12:00 , 927 characters |  + 0 - 0   English
转载请保留本行原始出处声明信息 : http://www.zeali.net/entry/686 MaDe1nZEAL
标签 ( PHP ):  ,  ,  , 

系统环境: LNMP (php-fpm) + APC ;通过 svn export 的二次封装实现根据版本号的源代码自动发布到生产环境服务器。

问题:更新后随机出现各种PHP运行时错误,通常都是 Class Not Found 之类的错误。但实际文件内容是正确的。重启 php-fpm 后自动恢复正常。通常在大版本更新涉及到比较多的文件写入时出现。

原因:APC默认是通过系统文件的mtime来判断是否需要更新缓存的,而svn export的时候修改的是文件的ctime;这就导致在大批量更新同时又触发到APC对其中某个写入到一半的文件的访问时,APC获取到的是不完整的文件内容,又不会在文件完成写入ctime变化之后再次尝试获取正确的文件版本。

修正:配置 php.ini 的参数 apc.stat_ctime = 1



modifies APC's behavior to check the ctime instead of the mtime. The ctime (creation/change) of a file is updated every time a file is copied or its permissions are changed (since they reside in the inodes of the file). The mtime is reset only when the file is actually modified: unzipping a file or rsyncing it may not affect mtime.

For this reason, ctime causes more false positives (that have to be cached again) but it's more reliable against all deployment methods which may not affect mtime.

Since 2005.04.27  梦想 就像鸡蛋 要么孵化 要么臭掉RSS Feed (Entries) | Back To Home | @ZEAL | 沪ICP备05024379号