Bug #65559 [Com]: Opcache: cache not cleared if changes occur while running
| From: | zoeslam at gmail dot com | Date: | Mon, 25 Nov 2013 10:54:43 +0000 |
| Subject: | Bug #65559 [Com]: Opcache: cache not cleared if changes occur while running | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-182913@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65559&edit=1
ID: 65559
Comment by: zoeslam at gmail dot com
Reported by: zoeslam at gmail dot com
Summary: Opcache: cache not cleared if changes occur while
running
Status: Assigned
Type: Bug
Package: opcache
Operating System: Ubuntu
PHP Version: 5.5.3
Assigned To: dmitry
Block user comment: N
Private report: N
New Comment:
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.
Previous Comments:
------------------------------------------------------------------------
[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.
------------------------------------------------------------------------
[2013-11-19 13:46:45] Terry at ellisons dot org dot uk
Why is this a problem? This is the analog of apc.stat. The only material difference here is that
apc.stat=1 by default. OPcache defaults are different, but this is clearly documented. If you want
OPcache always to revalidate scripts, then set opcache.revalidate_freq=0 as per README and
documentation.
------------------------------------------------------------------------
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