MCPcopy Create free account
hub / github.com/F-Stack/f-stack / clusterHandleConfigEpochCollision

Function clusterHandleConfigEpochCollision

app/redis-6.2.6/src/cluster.c:1167–1182  ·  view source on GitHub ↗

This function is called when this node is a master, and we receive from * another master a configuration epoch that is equal to our configuration * epoch. * * BACKGROUND * * It is not possible that different slaves get the same config * epoch during a failover election, because the slaves need to get voted * by a majority. However when we perform a manual resharding of the cluster * the n

Source from the content-addressed store, hash-verified

1165 * end with a different configuration epoch.
1166 */
1167void clusterHandleConfigEpochCollision(clusterNode *sender) {
1168 /* Prerequisites: nodes have the same configEpoch and are both masters. */
1169 if (sender->configEpoch != myself->configEpoch ||
1170 !nodeIsMaster(sender) || !nodeIsMaster(myself)) return;
1171 /* Don't act if the colliding node has a smaller Node ID. */
1172 if (memcmp(sender->name,myself->name,CLUSTER_NAMELEN) <= 0) return;
1173 /* Get the next ID available at the best of this node knowledge. */
1174 server.cluster->currentEpoch++;
1175 myself->configEpoch = server.cluster->currentEpoch;
1176 clusterSaveConfigOrDie(1);
1177 serverLog(LL_VERBOSE,
1178 "WARNING: configEpoch collision with node %.40s."
1179 " configEpoch set to %llu",
1180 sender->name,
1181 (unsigned long long) myself->configEpoch);
1182}
1183
1184/* -----------------------------------------------------------------------------
1185 * CLUSTER nodes blacklist

Callers 1

clusterProcessPacketFunction · 0.85

Calls 1

clusterSaveConfigOrDieFunction · 0.85

Tested by

no test coverage detected