Skip to content

[Cache] Tag invalidation does not persist after script execution #27147

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

Closed
Loupax opened this issue May 4, 2018 · 2 comments
Closed

[Cache] Tag invalidation does not persist after script execution #27147

Loupax opened this issue May 4, 2018 · 2 comments

Comments

@Loupax
Copy link

Loupax commented May 4, 2018

Q A
Bug report? yes
Feature request? no
BC Break report? no
RFC? no
Symfony version ^4.0

I am using the TagAwareAdapter so I can invalidate my REDIS cache by tag. The problem is that, while the cache item gets invalidated, this change does not persist between requests.

See this reproduction repo , it has four commands:
One that populates the cache, one that invalidates the cache by tag, one that fetches the keys and one that does all three in a single command.

Expected behaviour:

$ bin/console app:add
$ bin/console app:invalidate
$ bin/console app:get

The final command should output:

item-0, isHit:false
item-1, isHit:false
item-2, isHit:false
item-3, isHit:false
item-4, isHit:false

Actual output:

item-0, isHit:true
item-1, isHit:true
item-2, isHit:true
item-3, isHit:true
item-4, isHit:true

Running the command $ bin/console app:add-invalidate-and-get works as expected

@harmbandstra
Copy link

@Loupax I ran into the same issue. You can downgrade the cache component to 4.0.8 as a workaround.

@Loupax
Copy link
Author

Loupax commented May 4, 2018

@harmbandstra can confirm, downgrading to 4.0.8 works correctly right now

nicolas-grekas added a commit that referenced this issue May 5, 2018
…pter (dmaicher)

This PR was squashed before being merged into the 3.4 branch (closes #27158).

Discussion
----------

[Cache] fix logic for fetching tag versions on TagAwareAdapter

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #27147
| License       | MIT
| Doc PR        | -

There was a problem introduced in #27007 which breaks tag invalidation.

From what I can see there were some cases when the actual tag versions were never fetched from the tags pool and version=0 was used.

@nicolas-grekas this is my attempt of understanding the logic within `TagAwareAdapter`. Please have a look if this makes sense to you 😉

Commits
-------

d3790ca [Cache] fix logic for fetching tag versions on TagAwareAdapter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants