fix: resolve race conditions in Redis TTL and prevent cache test state leakage#10374
Open
gr8man wants to merge 1 commit into
Open
fix: resolve race conditions in Redis TTL and prevent cache test state leakage#10374gr8man wants to merge 1 commit into
gr8man wants to merge 1 commit into
Conversation
Contributor
Author
|
IMPORTANT Note to reviewers and developers: Please ensure that tests are run regularly with the --order-by=random flag during development. Identifying test pollution and global state leakage bugs at a later stage is extremely difficult and time-consuming, as these failures only manifest under very specific test suite execution orders. |
7827c6e to
260ac10
Compare
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.
Description
This PR fixes persistent and random failures when running the cache test suite (
tests/system/Cache) repeatedly or in a random order (--order-by=random).Ref: #9968
Changes included:
PredisHandlerandRedisHandlerto use theexpire()command directly with a relative TTL (in seconds) instead of calculating an absolute timestamp forexpireAt()via PHP'sTime::now(). Using a PHP-generated timestamp makes the cache vulnerable to clock drifts between the PHP server and the Redis server. This drift resulted in random test failures (e.g.testGetandtestRememberfailing to assertnullafter waiting for 3 seconds).FileHandlerTest,RedisHandlerTest,PredisHandlerTest,ApcuHandlerTest,MemcachedHandlerTest) inheritedtestDeleteMatchingwhich temporarily created 50-100 cache entries. ThetearDown()methods previously only deleted three predefined default keys (key1,key2,key3), leaving dozens of dummy keys behind. This leaked state caused randomDirectory not emptysystem errors forFileHandlerand false-positive assertion failures in tests liketestDeleteMatchingNothing.tearDown()now properly calls$this->handler->clean()to guarantee a perfectly clean state for the next random test.ApcuHandlerTest'ssetUp()to verifyapcu_enabled(). This correctly skips the test when APCu CLI mode is disabled instead of falling back to theDummyHandlerand producing cascaded test failures.Checklist: