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

Function clearNodeFailureIfNeeded

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

This function is called only if a node is marked as FAIL, but we are able * to reach it again. It checks if there are the conditions to undo the FAIL * state. */

Source from the content-addressed store, hash-verified

1313 * to reach it again. It checks if there are the conditions to undo the FAIL
1314 * state. */
1315void clearNodeFailureIfNeeded(clusterNode *node) {
1316 mstime_t now = mstime();
1317
1318 serverAssert(nodeFailed(node));
1319
1320 /* For slaves we always clear the FAIL flag if we can contact the
1321 * node again. */
1322 if (nodeIsSlave(node) || node->numslots == 0) {
1323 serverLog(LL_NOTICE,
1324 "Clear FAIL state for node %.40s: %s is reachable again.",
1325 node->name,
1326 nodeIsSlave(node) ? "replica" : "master without slots");
1327 node->flags &= ~CLUSTER_NODE_FAIL;
1328 clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG);
1329 }
1330
1331 /* If it is a master and...
1332 * 1) The FAIL state is old enough.
1333 * 2) It is yet serving slots from our point of view (not failed over).
1334 * Apparently no one is going to fix these slots, clear the FAIL flag. */
1335 if (nodeIsMaster(node) && node->numslots > 0 &&
1336 (now - node->fail_time) >
1337 (server.cluster_node_timeout * CLUSTER_FAIL_UNDO_TIME_MULT))
1338 {
1339 serverLog(LL_NOTICE,
1340 "Clear FAIL state for node %.40s: is reachable again and nobody is serving its slots after some time.",
1341 node->name);
1342 node->flags &= ~CLUSTER_NODE_FAIL;
1343 clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG);
1344 }
1345}
1346
1347/* Return true if we already have a node in HANDSHAKE state matching the
1348 * specified ip address and port number. This function is used in order to

Callers 1

clusterProcessPacketFunction · 0.85

Calls 2

clusterDoBeforeSleepFunction · 0.85
mstimeFunction · 0.70

Tested by

no test coverage detected