mirror of
https://github.com/fluencelabs/redis
synced 2025-03-25 20:01:04 +00:00
Cluster: master node must clear its hash slots when turning into a slave.
When a master turns into a slave after a failover event, make sure to clear the assigned slots before setting up the replication, as a slave should never claim slots in an explicit way, but just take over the master slots when replacing its master.
This commit is contained in:
parent
506f9a42b0
commit
e006407fd0
@ -907,6 +907,7 @@ int clusterProcessPacket(clusterLink *link) {
|
|||||||
oldmaster == server.cluster->myself)
|
oldmaster == server.cluster->myself)
|
||||||
{
|
{
|
||||||
redisLog(REDIS_WARNING,"One of my slaves took my place. Reconfiguring myself as a replica of %.40s", sender->name);
|
redisLog(REDIS_WARNING,"One of my slaves took my place. Reconfiguring myself as a replica of %.40s", sender->name);
|
||||||
|
clusterDelNodeSlots(server.cluster->myself);
|
||||||
clusterSetMaster(sender);
|
clusterSetMaster(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1836,11 +1837,13 @@ int verifyClusterConfigWithData(void) {
|
|||||||
* SLAVE nodes handling
|
* SLAVE nodes handling
|
||||||
* -------------------------------------------------------------------------- */
|
* -------------------------------------------------------------------------- */
|
||||||
|
|
||||||
/* Set the specified node 'n' as master. */
|
/* Set the specified node 'n' as master. Setup the node as a slave if
|
||||||
|
* needed. */
|
||||||
void clusterSetMaster(clusterNode *n) {
|
void clusterSetMaster(clusterNode *n) {
|
||||||
clusterNode *myself = server.cluster->myself;
|
clusterNode *myself = server.cluster->myself;
|
||||||
|
|
||||||
redisAssert(n != myself);
|
redisAssert(n != myself);
|
||||||
|
redisAssert(myself->numslots == 0);
|
||||||
|
|
||||||
if (myself->flags & REDIS_NODE_MASTER) {
|
if (myself->flags & REDIS_NODE_MASTER) {
|
||||||
myself->flags &= ~REDIS_NODE_MASTER;
|
myself->flags &= ~REDIS_NODE_MASTER;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user