Closed
Description
Symfony version(s) affected
>=5.3
Description
According to official documentation on redis adapter it is possible to use redis sentinel as DSN for cache component:
RedisAdapter::createConnection(
'redis:?host[redis1:26379]&host[redis2:26379]&host[redis3:26379]&redis_sentinel=mymaster'
);
However doing so leads to the following problems:
- defining several hosts along with redis_sentinel param in dsn creates instance of
RedisArray
instead ofRedisSentinel
inside thecreateConnection
method ofRedisTrait
- actual redis master is evaluated only once during connection initialization. For long-running applications it is the same as using direct connection to redis without sentinel
How to reproduce
Setup at least 2 redis sentinels and master-slave servers. Try to configure dsn to use sentinel.
Possible Solution
To mitigate the problems sentinel proxy class can be implemented in the same way as existing Redis*Proxy
classes. The class should evaluate redis master at runtime and handle "Writing against read only replica" error.
Additional Context
No response