Repository navigation
[6.x] Reset memoized Stache state when an Octane request arrives - #15858
Open
DanielDarrenJones wants to merge 2 commits into
Open
DanielDarrenJones wants to merge 2 commits into
DanielDarrenJones wants to merge 2 commits into
Conversation
The stores are made when the app boots, so an Octane worker uses the same ones for every request. They were only told to forget what they'd memoized between queued jobs, so a worker never saw an entry that another process created or renamed.
DanielDarrenJones
marked this pull request as ready for review
November 12, 2026 00:10
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.
Fixes #15857.
The Stache's stores are made when the app boots, so under Octane a worker uses the same ones for every request it handles. Each store memoizes its paths the first time it's used. An entry that another process creates or renames afterwards isn't in that list, so the worker can't find it and its page is a 404 until the worker is reloaded.
Queue workers had the same problem, and the stores and indexes are told to forget what they've memoized before each job (
resetMemoizedStateBetweenJobs()). This does the same when an Octane request arrives.Checked
Through Octane's own
Laravel\Octane\Workerclass, with a second PHP process doing the writes (the script is in the issue):This drives the worker in one process rather than through a running FrankenPHP, Swoole or RoadRunner server.
Cost
Each request reads the paths of the stores it uses from the cache again, as a request under PHP-FPM does. On a site of 358 entries, three pages served 30 times each through the worker, alternating before and after for three rounds, came out within 2% of each other either way (around 287 ms, 212 ms and 258 ms). I haven't measured it on a large site, where the lists are longer.
Not covered
With the Stache watcher on, a store still only checks for changed files once (
$fileChangesHandled), so a file edited outside Statamic isn't picked up by a running worker. That's the same for queue workers today and is left alone here.Tests
it_resets_memoized_store_and_index_state_when_an_octane_request_arrivesinStache\ServiceProviderTest, next to the between-jobs tests. It fires the event by name, and fails without the change.