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
| 1204 | * end with a different configuration epoch. |
| 1205 | */ |
| 1206 | void clusterHandleConfigEpochCollision(clusterNode *sender) { |
| 1207 | /* Prerequisites: nodes have the same configEpoch and are both masters. */ |
| 1208 | if (sender->configEpoch != myself->configEpoch || |
| 1209 | !nodeIsMaster(sender) || !nodeIsMaster(myself)) return; |
| 1210 | /* Don't act if the colliding node has a smaller Node ID. */ |
| 1211 | if (memcmp(sender->name,myself->name,CLUSTER_NAMELEN) <= 0) return; |
| 1212 | /* Get the next ID available at the best of this node knowledge. */ |
| 1213 | g_pserver->cluster->currentEpoch++; |
| 1214 | myself->configEpoch = g_pserver->cluster->currentEpoch; |
| 1215 | clusterSaveConfigOrDie(1); |
| 1216 | serverLog(LL_VERBOSE, |
| 1217 | "WARNING: configEpoch collision with node %.40s." |
| 1218 | " configEpoch set to %llu", |
| 1219 | sender->name, |
| 1220 | (unsigned long long) myself->configEpoch); |
| 1221 | } |
| 1222 | |
| 1223 | /* ----------------------------------------------------------------------------- |
| 1224 | * CLUSTER nodes blacklist |
no test coverage detected