-
Notifications
You must be signed in to change notification settings - Fork 236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PsrCachedReader::fetchFromCache might return null instead of array under high request rate #457
Comments
Which PSR cache implementation are you using ? This behavior looks weird to me. AFAICT, the only way |
It's Symfony\Component\Cache\Adapter\PhpArrayAdapter |
@stof I think it does not really depend on the real Cache Provider used because this method except to return only Please take a look at the public interface from
It seems the method signature should be changed to
Or the method should return an empty array for example
|
Well, that description is the whole point. It returns |
Yes, the point is in the description, so the |
No, it shouldn't. If they occur, the cache implementation is broken and should be fixed instead. If you can reproduce this issue with Symfony Cache, you should report it to Symfony. That being said, I'd really recommend to not evaluate annotations on a hot path or in high-load scenarios, even with a cached reader. Cache the information you extract from the annotations, not the annotations themselves. |
I had a similar case while ago using symfony ACL cache symfony/security-acl#47 It happens while using Redis with eviction policy, so key got removed in moments between |
|
Hi everyone.
We are fandom and very rare error
request.CRITICAL: Uncaught PHP Exception TypeError: "Doctrine\Common\Annotations\PsrCachedReader::fetchFromCache(): Return value must be of type array, bool returned" at ...
This usually happens on applications with the high request rate and some of such caches are empty.
The working scenario - new code release which requires to flush caches in order to new changes took in place.
When we debug the problem - it is appeared, when some of the requests hit that method and retrieve CacheItem, it has isHit property "true" but value "null".
Obviously, we made sure nothing overrides this cache items with null values.
Therefore we made conclusion this is "race condition" problem
We tried different approaches as a hotfix:
We understand that problem is quite unique and the package is not actively maintained, but since this class is final, it is hard to override this code and it would be great to have working solution in one of the next releases.
Thank you
The text was updated successfully, but these errors were encountered: