ctdb_election_data(rec, &myem);
- /* try to use a unbanned node */
- if ((em->node_flags & NODE_FLAGS_BANNED) &&
- !(myem.node_flags & NODE_FLAGS_BANNED)) {
- cmp = 1;
- }
- if (!(em->node_flags & NODE_FLAGS_BANNED) &&
- (myem.node_flags & NODE_FLAGS_BANNED)) {
- cmp = -1;
- }
+ /* we cant win if we are banned */
+ if (rec->node_flags & NODE_FLAGS_BANNED) {
- return 0;
++ return false;
+ }
- /* try to use a healthy node */
- if (cmp == 0) {
- if ((em->node_flags & NODE_FLAGS_UNHEALTHY) &&
- !(myem.node_flags & NODE_FLAGS_UNHEALTHY)) {
- cmp = 1;
- }
- if (!(em->node_flags & NODE_FLAGS_UNHEALTHY) &&
- (myem.node_flags & NODE_FLAGS_UNHEALTHY)) {
- cmp = -1;
- }
+ /* we will automatically win if the other node is banned */
+ if (em->node_flags & NODE_FLAGS_BANNED) {
- return 1;
++ return true;
}
/* try to use the most connected node */
goto again;
}
- if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
+ /* if recovery master is disconnected we must elect a new recmaster */
+ if (nodemap->nodes[j].flags & NODE_FLAGS_DISCONNECTED) {
+ DEBUG(0, ("Recmaster node %u is disconnected. Force reelection\n", nodemap->nodes[j].pnn));
+ force_election(rec, mem_ctx, pnn, nodemap);
+ goto again;
+ }
+
- /* grap the nodemap from the recovery master to check if it is banned*/
++ /* grap the nodemap from the recovery master to check if it is banned */
+ ret = ctdb_ctrl_getnodemap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn,
+ mem_ctx, &remote_nodemap);
+ if (ret != 0) {
+ DEBUG(0, (__location__ " Unable to get nodemap from recovery master %u\n",
+ nodemap->nodes[j].pnn));
+ goto again;
+ }
+
+
+ if (remote_nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) {
DEBUG(0, ("Recmaster node %u no longer available. Force reelection\n", nodemap->nodes[j].pnn));
force_election(rec, mem_ctx, pnn, nodemap);
goto again;