Bug #65559 [Com]: Opcache: cache not cleared if changes occur while running
| From: | roger dot qiu at polycademy dot com | Date: | Wed, 26 Mar 2014 01:20:47 +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-184889@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: roger dot qiu at polycademy dot com
Reported by: zoeslam at gmail dot com
Summary: Opcache: cache not cleared if changes occur while
running
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:
This is still a problem, because include is sometimes used for non-source code files that can be
changed under 1 second during runtime.
https://github.com/tedivm/Stash/pull/135#issuecomment-38640785
Previous Comments:
------------------------------------------------------------------------
[2013-11-26 10:00:36] ab@php.net
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)
------------------------------------------------------------------------
[2013-11-26 07:37:19] dmitry@php.net
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)
------------------------------------------------------------------------
[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
------------------------------------------------------------------------
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