Edit report at https://bugs.php.net/bug.php?id=65559&edit=1
ID: 65559
Updated by: dmitry@php.net
Reported by: zoeslam at gmail dot com
Summary: Opcache: cache not cleared if changes occur while
running
-Status: Assigned
+Status: Closed
Type: Bug
Package: opcache
Operating System: Ubuntu
PHP Version: 5.5.3
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of dmitry@zend.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=a8c7e50f4d7d73797615734978259d640b3835c1
Log: Fixed bug #65559 (Opcache: cache not cleared if changes occur while running)
Previous Comments:
------------------------------------------------------------------------
[2013-11-25 10:54:43] zoeslam at gmail dot com
Hi dmitry, almost all http requests last less than 1 second, and it's common to write this
cache algorithm:
$var = include $cachefile;
if (must_renew($var)) {
file_put_contents($cachefile, renew($var));
$var = include $cachefile;
}
use($var);
So I think APC did a workaround just because of that common usage.
Your workaround works, but it' pretty bad to couple a general algorithm to teh cache subsystem.
------------------------------------------------------------------------
[2013-11-25 10:41:51] dmitry@php.net
APC made a hack to prevent caching of just updated files.
This makes the test passed.
With opcache.revalidate_freq=0 OPCache checks file modification time on each include(), but the test
script most probably makes two writes in a single second.
So file modification times are the same. If you insert sleep(1) between inclue()s, it works as
expected.
To workaround the problem you may add the file into blacklist or use opcache_invalidate():
if (function_exists("opcache_invalidate")) opcache_invalidate($file, true);
We may also hack OPCache similar to APC, but I'm not sure it's the right way.
------------------------------------------------------------------------
[2013-11-21 22:01:45] nanobreaker at mail dot bg
I have the same problem. If I change a file nothing happens. For development purposes I tried to
disable OPCache, but that doesn't work as well. Only way I can fix this problem is by rebooting
the system.
Details:
Ubuntu Server 13.10 x64
PHP 5.5.3
Apache 2.4.6
------------------------------------------------------------------------
[2013-11-19 14:04:26] arjen at react dot com
-d opcache.revalidate_freq=0 will result in OPcache checking for updates on every request.
You change the content DURING the request, so OPcache won't check for updates during the
request.
http://www.php.net/manual/en/apc.configuration.php#ini.apc.stat
"This defaults to on, forcing APC to stat (check) the script on each request to determine if it
has been modified."
Reads the same as opcache.revalidate. Because of your bugreport I guess apc.stat=1 checks the file
on disk for modification on every include/require. And not just once per request, which is quite
different..
------------------------------------------------------------------------
[2013-11-19 13:52:48] zoeslam at gmail dot com
Well, just tested with
php -d opcache.enable=1 -d opcache.enable_cli=1 -d opcache.revalidate_freq=0 test.php
and the result is the same, int(1), so the issue is still alive.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=65559--
Edit this bug report at https://bugs.php.net/bug.php?id=65559&edit=1