Repository navigation
Conversation
…nd apart in the past, so the answer put() is writing is always the newest -- with APCu the folder is trimmed inside put(), and the mtimes in the future made the new answer the oldest or as old as the first when a second passed It failed now and then on a slow leg (PHP 8.0 with APCu: "the newest kept, the oldest gone"): which answer was taken out depended on whether the clock moved to the next second during the loop. It still holds the same: past the folder's share the oldest go, the newest stays, with and without APCu.
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.
What fails
CacheTest > RSF04-03 the disk's cap (http-cache-disk)fails now and then ona slow leg. It was seen on
PHP 8.0 + APCu, in a run of a92a37b plus the roletest fix:
https://github.com/se7enxweb/request-shield/actions/runs/38120981093/job/114415779306
The same commit passed on that leg in the next run, so the failure depends on timing.
Why
The test writes answers in a loop, one after another, and after each write
sets the mtimes by hand,
touch($file, time() + $n), so the older answersstay older. Those mtimes lie in the future.
With APCu,
FileCache::put()trims the folder insideput(), while itwrites the new answer, whose mtime is the real "now". Next to answers dated
time() + 1,time() + 2…, the answer being written is the oldest one inthe folder, or as old as the first one when the clock moves to the next second
during the loop. Which answer is taken out then depends on whether a second
passed, not on the order of writing. A fast machine finishes within one
second and passes. A slow 8.0 leg sometimes does not.
The fix
Test only, in
tests/CacheTest.php: the mtimes are set one second apart inthe past,
touch($file, $base + $n)with$base = time() - 100. Theanswer
put()is writing is then always the newest, as on a real site. Thetest still checks the same thing, with and without APCu: past the folder's
share, the oldest answers go and the newest stays.
Tested
php tests/run.php "disk's cap"8 times in a rowwith APCu (
-d apc.enable_cli=1), and once without it: all passed.https://github.com/se7enxweb/request-shield/actions/runs/38122519080
The disk-cap test passes on every leg. The one failure in that run is a
demo row on
PHP 8.0 (file store)answered with status 0. That is the PHP8.0 built-in server and is unrelated; see Updated: A demo test whose request gets no answer says whether the demo's server ended, and how #8 and PHP 8.0.30 legs: segfaults (exit 139) in FeedsTest and status 0 from the demo's built-in server #9.