places.
create a new helper function to generate new generation id values that
know about the invalid id and avoids generating it.
update the ctdb status tool to know about the invalid generation id and
print the string INVALID instead
(This used to be ctdb commit
4fbcd189543cb8a92227fdcd3d158472e558ccda)
double max_lockwait_latency;
};
+
+#define INVALID_GENERATION 1
/* table that contains the mapping between a hash value and lmaster
*/
struct ctdb_vnn_map {
We are now banned so we shouldnt service database calls
anymore.
*/
- ctdb->vnn_map->generation = 1;
+ ctdb->vnn_map->generation = INVALID_GENERATION;
ctdb_start_freeze(ctdb);
ctdb_release_all_ips(ctdb);
}
}
+/* Create a new random generation ip.
+ The generation id can not be the INVALID_GENERATION id
+*/
+static uint32_t new_generation(void)
+{
+ uint32_t generation;
+
+ while (1) {
+ generation = random();
+
+ if (generation != INVALID_GENERATION) {
+ break;
+ }
+ }
+
+ return generation;
+}
+
/*
we are the recmaster, and recovery is needed - start a recovery run
*/
DEBUG(0, (__location__ " Recovery initiated due to problem with node %u\n", culprit));
/* pick a new generation number */
- generation = random();
+ generation = new_generation();
/* change the vnnmap on this node to use the new generation
number but not on any other nodes.
/* build a new vnn map with all the currently active and
unbanned nodes */
- generation = random();
+ generation = new_generation();
vnnmap = talloc(mem_ctx, struct ctdb_vnn_map);
CTDB_NO_MEMORY(ctdb, vnnmap);
vnnmap->generation = generation;
}
/* initialize the vnn mapping table now that we have num_nodes setup */
-/*
-XXX we currently initialize it to the maximum number of nodes to
-XXX make it behave the same way as previously.
-XXX Once we have recovery working we should initialize this always to
-XXX generation==0 (==invalid) and let the recovery tool populate this
-XXX table for the daemons.
-*/
ctdb->vnn_map = talloc(ctdb, struct ctdb_vnn_map);
CTDB_NO_MEMORY(ctdb, ctdb->vnn_map);
- ctdb->vnn_map->generation = 1;
+ ctdb->vnn_map->generation = INVALID_GENERATION;
ctdb->vnn_map->size = ctdb->num_nodes;
ctdb->vnn_map->map = talloc_array(ctdb->vnn_map, uint32_t, ctdb->vnn_map->size);
CTDB_NO_MEMORY(ctdb, ctdb->vnn_map->map);
DEBUG(0, ("Unable to get vnnmap from node %u\n", options.vnn));
return ret;
}
- printf("Generation:%d\n",vnnmap->generation);
+ if (vnnmap->generation == INVALID_GENERATION) {
+ printf("Generation:INVALID\n");
+ } else {
+ printf("Generation:%d\n",vnnmap->generation);
+ }
printf("Size:%d\n",vnnmap->size);
for(i=0;i<vnnmap->size;i++){
printf("hash:%d lmaster:%d\n", i, vnnmap->map[i]);