Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[Cache] Fix invalidating tags on Redis <5#43158

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
fabpot merged 1 commit intosymfony:4.4fromwouterj:issue-42126/redis3-replication
Sep 26, 2021

Conversation

@wouterj
Copy link
Member

QA
Branch?5.3
Bug fix?yes
New feature?no
Deprecations?no
TicketsFix#42126
LicenseMIT
Doc PR-

https://redis.io/commands/eval#replicating-commands-instead-of-scripts

Note: starting with Redis 5, the replication method described in this section (scripts effects replication) is the default and does not need to be explicitly enabled.

Starting with Redis 3.2, it is possible to select an alternative replication method. Instead of replicating whole scripts, we can just replicate single write commands generated by the script. We call this script effects replication.

To enable script effects replication you need to issue the following Lua command before the script performs a write:

redis.replicate_commands()

@nicolas-grekas
Copy link
Member

<5 instead of <3? What about doDeleteYieldTags()?

@wouterjwouterj changed the title[Cache] Fix invalidating tags on Redis <3[Cache] Fix invalidating tags on Redis <5Sep 24, 2021
@wouterjwouterjforce-pushed theissue-42126/redis3-replication branch from7539aea to64784d2CompareSeptember 24, 2021 08:51
@wouterj
Copy link
MemberAuthor

What about doDeleteYieldTags()?

This new replication method is only required when the commands are non deterministic. It seems like thedoDeleteYieldTags() script is deterministic. For completeness, I've started a redis:3 container locally and ran theRedisTagAwareAdapterTest integration tests with this container. They all passed with the changes in this PR.

I've also updated the PR to handle any exception better. Currently, users get a PHP Error: "Cannot use object of type RedisException as array". After this PR, they'll get the actual redis exception.

nicolas-grekas and ging-dev reacted with heart emoji

@wouterjwouterjforce-pushed theissue-42126/redis3-replication branch from64784d2 to61e00cdCompareSeptember 24, 2021 08:54
@wouterjwouterj changed the base branch from5.3 to4.4September 24, 2021 08:55
@wouterjwouterj modified the milestones:5.3,4.4Sep 24, 2021
@wouterjwouterjforce-pushed theissue-42126/redis3-replication branch from61e00cd todbe0cf7CompareSeptember 24, 2021 09:01
@nicolas-grekas
Copy link
Member

For my understanding, when did you encounterRedisException being returned? Is that a dev-time only issue or can this happen in regular operations? I'm asking because the cache adapters are not supposed to fail when there is an issue.

@wouterj
Copy link
MemberAuthor

We had this occur when invalidating caches in production.

I'm not sure what would be the best way forward. If there is an error, nothing is invalidated. So simply logging the exception and retuning would probably not be correct either.

@nicolas-grekas
Copy link
Member

nicolas-grekas commentedSep 24, 2021
edited
Loading

Do you know what theRedisException was about?

@wouterj
Copy link
MemberAuthor

wouterj commentedSep 25, 2021
edited
Loading

Do you know what the RedisException was about?

Yeah, it was about the error in the lua script that is fixed in this PR:

ERR Error running script (call to f_cea3ea3b59f1b3411febbbeb5f94de8a695cec73): @user_script:19: @user_script: 19: Write commands not allowed after non deterministic commands. Call redis.replicate_commands() at the start of your script in order to switch to single commands replication mode.

So in theory, you will not get this exception. But I don't know anything about Redis, so I guess maybe there is something else in this script that breaks for e.g. Redis 4 or Redis 6 in the future?

@nicolas-grekas
Copy link
Member

Can we callCacheItem::log when we have the exception somehow?

@jderusse
Copy link
Member

So in theory, you will not get this exception. But I don't know anything about Redis, so I guess maybe there is something else in this script that breaks for e.g. Redis 4 or Redis 6 in the future?

methodSSCAN is not deterministic (becauseSETs are unordered), that's why, in Redis 4, you have to tell Redis to replicate commands.

more infohttps://redis.io/commands/eval#replicating-commands-instead-of-scripts andhttps://redis.io/commands/EVAL#scripts-with-deterministic-writes

wouterj reacted with thumbs up emoji

@wouterjwouterjforce-pushed theissue-42126/redis3-replication branch fromdbe0cf7 toeb09827CompareSeptember 25, 2021 11:08
@wouterj
Copy link
MemberAuthor

Can we callCacheItem::log when we have the exception somehow?

Oh, didn't know about this helper method. I've updated the PR with your suggestions: any exception is now logged and not thrown, anddoInvalidateTags() nows returnsfalse when there was an exception.

Copy link
Member

@nicolas-grekasnicolas-grekas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

(once psalm failure is fixed)

@wouterjwouterjforce-pushed theissue-42126/redis3-replication branch fromeb09827 tofda7e7eCompareSeptember 25, 2021 11:31
@fabpot
Copy link
Member

Thank you@wouterj.

@fabpotfabpot merged commit5c5fd0c intosymfony:4.4Sep 26, 2021
@wouterjwouterj deleted the issue-42126/redis3-replication branchSeptember 26, 2021 16:37
This was referencedSep 28, 2021
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@fabpotfabpotfabpot approved these changes

@nicolas-grekasnicolas-grekasnicolas-grekas approved these changes

@chalasrchalasrchalasr approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

4.4

Development

Successfully merging this pull request may close these issues.

[Cache] invalidating tags breaks after updating to symfony/cache 5.3.3 with Redis versions below 5.x

6 participants

@wouterj@nicolas-grekas@jderusse@fabpot@chalasr@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp