Error reconnect in the master-replica model of Redis-Server with Redis Sentinel
lazyky opened this issue · comments
Kaiyu Zhu commented
Description
When the master node of redis-server crash, reconnecting will not obtain the address of the updated master node and generate an error:
Err(Client("Disconnected from server"))
To Reproduce
According to the document of redis.
- Build the master-replica model of Redis-Server with Redis Sentinel
+----+
| M1 |
| S1 |
+----+
|
+----+ | +----+
| R2 |----+----| R3 |
| S2 | | S3 |
+----+ +----+
Masters are called M1, M2, M3, ..., Mn.
Replicas are called R1, R2, R3, ..., Rn (R stands for replica).
Sentinels are called S1, S2, S3, ..., Sn.
- Crash the master node of redis-server
Additional context
SentinelConnection
- I checked the code of
SentinelConnection::reconnect()
and found that reconnecting usingStandaloneConnection::reconnect()
does not re-obtain the host and port of the updated master node
ClusterConnection
- Reconnect will use
ClusterConnection::connect_to_cluster()
inClusterConnection::reconnect()
to re-obtain the host and port of the node
Michaël Catanzariti commented
fixed in 45d0d3a