Avoid writing multiple keys when using redis in cluster mode #53940
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.
This PR should prevent Redis failing with a "Error processing EXEC across the cluster" error when using
Cache::flexible
with Redis in cluster mode (#53266).The problem is that open-source Redis doesn't allow commands that will update multiple "hash slots" (how Redis splits up keys). As far as I can tell this will only be an issue for Redis in cluster mode.
Redis has some info about this on their blog. See the "Redis Hashtags" section, in particular:
There is also a pre-existing issue for this problem that has been reported on phpredis: phpredis/phpredis#876
The issue there has existed since 2016 and the author of the extension suggests there may not have a path forwards due to limitations of Redis / complexity.
As such, I've opted to calling
put
multiple times when the connection is a cluster connection.This isn't a pretty solution, but I'm not sure what else we can do.