From d51a19f2ba43f3d7bd39609e6e717f59e0bbb3be Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Sun, 6 May 2007 10:16:48 +1000 Subject: [PATCH] create a helper function for recovery that pulls and merges all remote databases onto the local node (This used to be ctdb commit 5cecc47449c369f91e83389a94b987ac32b1e3f4) --- ctdb/direct/recoverd.c | 60 ++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/ctdb/direct/recoverd.c b/ctdb/direct/recoverd.c index 757dbdd2cc1..158163a067d 100644 --- a/ctdb/direct/recoverd.c +++ b/ctdb/direct/recoverd.c @@ -179,6 +179,37 @@ static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb return 0; } + +static int pull_all_remote_databases(struct ctdb_context *ctdb, struct ctdb_node_map *nodemap, uint32_t vnn, struct ctdb_dbid_map *dbmap, TALLOC_CTX *mem_ctx) +{ + int i, j, ret; + + /* pull all records from all other nodes across onto this node + (this merges based on rsn) + */ + for (i=0;inum;i++) { + for (j=0; jnum; j++) { + /* we dont need to merge with ourselves */ + if (nodemap->nodes[j].vnn == vnn) { + continue; + } + /* dont merge from nodes that are unavailable */ + if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) { + continue; + } + ret = ctdb_ctrl_copydb(ctdb, timeval_current_ofs(2, 0), nodemap->nodes[j].vnn, vnn, dbmap->dbids[i], CTDB_LMASTER_ANY, mem_ctx); + if (ret != 0) { + printf("Unable to copy db from node %u to node %u\n", nodemap->nodes[j].vnn, vnn); + return -1; + } + } + } + + return 0; +} + + + static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev, TALLOC_CTX *mem_ctx, uint32_t vnn, uint32_t num_active, struct ctdb_node_map *nodemap, struct ctdb_vnn_map *vnnmap) @@ -239,7 +270,7 @@ static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev, /* verify that we have all the databases any other node has */ ret = create_missing_local_databases(ctdb, nodemap, vnn, &dbmap, mem_ctx); if (ret != 0) { - printf("Unable to create missing remote databases\n"); + printf("Unable to create missing local databases\n"); return -1; } @@ -253,28 +284,17 @@ static int do_recovery(struct ctdb_context *ctdb, struct event_context *ev, } - /* pull all records from all other nodes across to this node - (this merges based on rsn) - */ - for (i=0;inum;i++) { - for (j=0; jnum; j++) { - /* we dont need to merge with ourselves */ - if (nodemap->nodes[j].vnn == vnn) { - continue; - } - /* dont merge from nodes that are unavailable */ - if (!(nodemap->nodes[j].flags&NODE_FLAGS_CONNECTED)) { - continue; - } - ret = ctdb_ctrl_copydb(ctdb, timeval_current_ofs(2, 0), nodemap->nodes[j].vnn, vnn, dbmap->dbids[i], CTDB_LMASTER_ANY, mem_ctx); - if (ret != 0) { - printf("Unable to copy db from node %u to node %u\n", nodemap->nodes[j].vnn, vnn); - return -1; - } - } + + /* pull all remote databases onto the local node */ + ret = pull_all_remote_databases(ctdb, nodemap, vnn, dbmap, mem_ctx); + if (ret != 0) { + printf("Unable to pull remote databases\n"); + return -1; } + + /* update dmaster to point to this node for all databases/nodes */ for (i=0;inum;i++) { for (j=0; jnum; j++) { -- 2.47.3