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. */
| 1352 | * to reach it again. It checks if there are the conditions to undo the FAIL |
| 1353 | * state. */ |
| 1354 | void clearNodeFailureIfNeeded(clusterNode *node) { |
| 1355 | mstime_t now = mstime(); |
| 1356 | |
| 1357 | serverAssert(nodeFailed(node)); |
| 1358 | |
| 1359 | /* For slaves we always clear the FAIL flag if we can contact the |
| 1360 | * node again. */ |
| 1361 | if (nodeIsSlave(node) || node->numslots == 0) { |
| 1362 | serverLog(LL_NOTICE, |
| 1363 | "Clear FAIL state for node %.40s: %s is reachable again.", |
| 1364 | node->name, |
| 1365 | nodeIsSlave(node) ? "replica" : "master without slots"); |
| 1366 | node->flags &= ~CLUSTER_NODE_FAIL; |
| 1367 | clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG); |
| 1368 | } |
| 1369 | |
| 1370 | /* If it is a master and... |
| 1371 | * 1) The FAIL state is old enough. |
| 1372 | * 2) It is yet serving slots from our point of view (not failed over). |
| 1373 | * Apparently no one is going to fix these slots, clear the FAIL flag. */ |
| 1374 | if (nodeIsMaster(node) && node->numslots > 0 && |
| 1375 | (now - node->fail_time) > |
| 1376 | (g_pserver->cluster_node_timeout * CLUSTER_FAIL_UNDO_TIME_MULT)) |
| 1377 | { |
| 1378 | serverLog(LL_NOTICE, |
| 1379 | "Clear FAIL state for node %.40s: is reachable again and nobody is serving its slots after some time.", |
| 1380 | node->name); |
| 1381 | node->flags &= ~CLUSTER_NODE_FAIL; |
| 1382 | clusterDoBeforeSleep(CLUSTER_TODO_UPDATE_STATE|CLUSTER_TODO_SAVE_CONFIG); |
| 1383 | } |
| 1384 | } |
| 1385 | |
| 1386 | /* Return true if we already have a node in HANDSHAKE state matching the |
| 1387 | * specified ip address and port number. This function is used in order to |
no test coverage detected