-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Cache] Redis PSR-6 getItem should not use transactions by default #22922
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
AFAIK, pipeline is not transactional. But since it uses one single connection to fetch several items at once, it gets them from the same server. Still, each read should be independent, I don't know why the master is always selected. Could it be a phpredis issue? |
Looks like phpredis implementation of "multi" may set the server into transaction mode and this mode only run on master, but not sure |
I have open an issue on phpredis phpredis/phpredis#1186 |
Thanks. How does a predis client behave? |
I got it: since a pipeline can have read and write ops, the master has to be selected... |
See #22924 |
Nice one @nicolas-grekas, this should work. |
…kas) This PR was merged into the 3.2 branch. Discussion ---------- [Cache] Dont use pipelining with RedisCluster | Q | A | ------------- | --- | Branch? | 3.é | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #22922 | License | MIT | Doc PR | - phpredis doesn't support pipelining with RedisCluster see https://github.com/phpredis/phpredis/blob/develop/cluster.markdown#pipelining and multiple operations (MSET/MGET) work but only "per-shard". We have to fetch keys one by one for now at least. Commits ------- eb93ac9 [Cache] Dont use pipelining with RedisCluster
File affected https://github.com/symfony/cache/blob/3e22d4ac7a60f7421f1c9e8dd15140f072834480/Traits/RedisTrait.php#L278
Function:
private function pipeline(\Closure $generator)
Redis PSR-6 getItem() operations are run inside the pipeline as a Redis transaction instead of a normal "get" operation, for instance check line 307 ($this->redis->multi). Redis transactions should be slower and they have side effect, in my case I'm running RedisCluster and I set it to distribute the load between the master and slaves but using transactions is running all operation only on the master server.
For instance it could be reproduced by using phpredis module and setting the RedisCluster connection to something like this:
I have done a quick fix, I have change the last else condition to no use transactions and in this case works fine, load get distributed.
this is the change I did for the test
If for any reason this is not a bug and PSR-6 Redis adapter is mean to wrap single operations into a transaction, would be nice to have an option to disable this behaviour.
The text was updated successfully, but these errors were encountered: