-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
Cache pool keys colide when Chain Adapter pool is used as a parent pool #49607
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
Comments
Thanks for the detailed report. Would you like to send a PR to fix the issue? |
Hey, thanks for your report! |
Could I get an answer? If I do not hear anything I will assume this issue is resolved or abandoned. Please get back to me <3 |
Issue still needs to be investigated. I will try to do a pull request. |
Hey, thanks for your report! |
Friendly reminder that this issue exists. If I don't hear anything I'll close this. |
I think this is the same as #54097, which provides a nice discussion on the topic. TL;DR don't make cache.app point to a tag-aware pool. |
Symfony version(s) affected
6.2.5
Description
Current behaviour
Let's create following cache pool config:
In this case every pool referencing
cache.app
has its own namespace for generating keys to APCU, as declared in documentation, see bellow.If I save item with key
ipsum
to cachecache.app.vokativ
with valueA
and another item with the same keyipsum
and valueB
to cachecache.app.user
, cache records do not colide and from cachecache.app.vokativ
is returnedA
value, from cachecache.app.user
is returnedB
value, even if pools share the same backendcache.app
(=cache.app.custom
).Now, let's have following buggy config:
We will modify main
cache.app.custom
to useChain Adapter
with APCU and Redis.In this case every pool referencing
cache.app
has THE SAME NAMESPACE for generating keys saved to thecache.app
pool.If I save item with key
ipsum
with valueA
to cachecache.app.vokativ
and another item with the same keyipsum
and valueB
to cachecache.app.user
, cache records do colide and from cachecache.app.vokativ
is returnedA
value, from cachecache.app.user
is returnedA
value, when the pools share the same backendcache.app
(=cache.app.custom
).I have checked it manually in Redis and the namespace for keys is the same. It is happening only, if parent pool is the chain type pool.
The problem is happing here -> https://github.com/symfony/cache/blob/6.2/DependencyInjection/CachePoolPass.php#L58 between lines 58 and 65, which results that
$tags[0]['name']
contains Service ID of Chained pool... so$id
of pool is never used in this case. I do not know the reason, why the code designed this way... but anyway it is not corresponding to actual documentation.From my point of view, even if I use chain adapter as parent adapter for new pool, new namespace should be introduced, otherwise cache key pools will colide and it will lead to unexpected cache pool results.
Expected behaviour
How to reproduce
Use following config to reproduce problem. You can use any kind of cache adapters contained in the chain.
Possible Solution
Change the behavior in the loop beginning here https://github.com/symfony/cache/blob/6.2/DependencyInjection/CachePoolPass.php#L58
The text was updated successfully, but these errors were encountered: