Description
Q | A |
---|---|
Bug report? | yes |
Feature request? | no |
BC Break report? | no |
RFC? | no |
Symfony version | 3.2 |
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:
// Create a cluster setting two nodes as seeds
$obj_cluster = new RedisCluster(NULL, Array("host:7000", "host:7001","host:7003"));
// Always distribute readonly commands between masters and slaves, at random
$obj_cluster->setOption(
RedisCluster::OPT_FAILOVER, RedsiCluster::FAILOVER_DISTRIBUTE
);
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
else {
$results[];
$i = 0;
foreach ($generator() as $command => $args) {
$ids[$i] = $args[0];
$results[$i++] = call_user_func_array(array($this->redis, $command), $args);
}
}
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.