php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #79005 validate_timestamps only has an effect when compiling the script
Submitted: 2019-12-20 08:59 UTC Modified: 2021-11-07 04:22 UTC
From: iquito at gmx dot net Assigned: cmb (profile)
Status: No Feedback Package: opcache
PHP Version: 7.4.2 OS: Debian Buster
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: iquito at gmx dot net
New email:
PHP Version: OS:

 

 [2019-12-20 08:59 UTC] iquito at gmx dot net
Description:
------------
When using php-fpm with opcache.validate_timestamps turned on and opcache.enable_file_override turned on, no script is ever reloaded in PHP 7.4.1 (it works as expected in 7.3.*). I am using the following options:

opcache.enable = 1
opcache.enable_cli = 0
opcache.validate_timestamps = 1
opcache.revalidate_freq = 0
opcache.use_cwd = 1
opcache.enable_file_override = 1

As soon as I set opcache.enable_file_override to 0, then validate_timestamps works again and changes to scripts are used by php-fpm. It does not matter what kind of script you are using - in my example, I used the following:

<?
//echo 'dada';
phpinfo();

And then I just changed the comment to the line with phpinfo, so the page should show "dada", but that does not happen.


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2020-02-11 06:49 UTC] iquito at gmx dot net
-Summary: opcache validate_timestamps does not work with enable_file_override +Summary: php_admin_value unexpected behavior for php-fpm with validate_timestamps -PHP Version: 7.4.1 +PHP Version: 7.4.2
 [2020-02-11 06:49 UTC] iquito at gmx dot net
After more trials and tribulations validate_timestamps for opcache did not work at all anymore for me anymore. I have a php.ini with "opcache.validate_timestamps = 0" and overwrote that value for a testing pool in php-fpm with:

php_admin_value[opcache.validate_timestamps] = 1

When I check phpinfo() it says that opcache.validate_timestamps is "On", but no script is ever reloaded when it has changed.

When I set "opcache.validate_timestamps = 1" in php.ini and change it via "php_admin_value[opcache.validate_timestamps] = 0" for a php-fpm pool it seems to work as expected both for the pools which "unset" validate_timestamps and for those that do validate the timestamps.
 [2020-02-12 06:44 UTC] iquito at gmx dot net
-Summary: php_admin_value unexpected behavior for php-fpm with validate_timestamps +Summary: validate_timestamps only has an effect when compiling the script
 [2020-02-12 06:44 UTC] iquito at gmx dot net
After validate_timestamps stopped working again I think I found the true cause. When storing a script in opcache, it sets a "timestamp" of the script in opcache. If validate_timestamps is turned off at the time of compiling the script for opcache, then that timestamp is set to zero, and the script is never checked thereafter. If validate_timestamps is turned on when compiling the script, a "timestamp" is set in the opcache data (with the last modification date of the file), and the script will be checked every time it is loaded, even if validate_timestamps is set to on after that.

This was not that way until PHP 7.4 - basically, the validate_timestamps option seems to only have an effect at the time of compiling a script, after that opcache decides itself what and how it will check the file according to the value in "timestamp". I am not sure why the change in PHP 7.4, or if this is just simply a bug. When using different pools where some are with validate_timestamps and some are without, this creates some weird issues - especially when using opcache_compile_file to pre-cache files, which can then lead to all those files always validating timestamps or never validating timestamps, no matter what pool with what validate_timestamps setting is used.
 [2021-10-28 16:07 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2021-10-28 16:07 UTC] cmb@php.net
> If validate_timestamps is turned off at the time of compiling
> the script for opcache, then that timestamp is set to zero, […]

If the timestamp of a persistent script is 0, that means that it
has been preloaded[1].  So apparently, you are using preloading,
and this is only available as of PHP 7.4.0, this explains the
difference to PHP 7.3.

[1] <https://github.com/php/php-src/blob/php-7.4.25/ext/opcache/ZendAccelerator.c#L1096-L1097>
 [2021-11-07 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 08:01:29 2024 UTC