Repository navigation
fix: restart worker scripts when opcache schedules a restart - #2843
Draft
nicolas-grekas wants to merge 1 commit into
Draft
nicolas-grekas wants to merge 1 commit into
nicolas-grekas wants to merge 1 commit into
Conversation
A worker uses opcache's shared memory for as long as its script runs. A restart of that memory reuses memory the worker still references. Once opcache waits for the threads of the process (php/php-src#24276), the restart never runs while workers are alive.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A worker uses opcache's shared memory for as long as its script runs. When opcache schedules a restart of that memory, the worker keeps using memory that the restart reuses. Once php/php-src#24276 is merged, the worker blocks the restart instead. Caching then stays off for regular requests until the workers restart for another reason.
Worker scripts now restart at their next request boundary when a restart is scheduled, and idle ones right away. The thread isn't rebooted, the script ends and starts again. This happens at most once a minute. That way, a cache too small for the app can't restart the workers in a loop, which was the concern of #2564.
With php/php-src#24276, a worker that starts while the restart is pending isn't cached by opcache. The worker checks this with
opcache_get_status()when it reachesfrankenphp_handle_request(). Once the restart is done, the script starts again after its next request. CI can't cover this case without that fix, so I checked it locally on PHP 8.4 with the patch applied.Draft until php/php-src#24276 is merged.