From: Martin Schwenke Date: Mon, 24 Feb 2020 08:51:19 +0000 (+1100) Subject: ctdb-recovery: Remove old code for creating missing databases X-Git-Tag: ldb-2.2.0~1258 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a66d181b6f6199fca362fcb0aa06513645b589d;p=thirdparty%2Fsamba.git ctdb-recovery: Remove old code for creating missing databases BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- diff --git a/ctdb/server/ctdb_recoverd.c b/ctdb/server/ctdb_recoverd.c index 6fddb44a014..14b6e0fca26 100644 --- a/ctdb/server/ctdb_recoverd.c +++ b/ctdb/server/ctdb_recoverd.c @@ -424,140 +424,6 @@ static int set_recovery_mode(struct ctdb_context *ctdb, return 0; } -/* - ensure all other nodes have attached to any databases that we have - */ -static int create_missing_remote_databases(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap, - uint32_t pnn, struct ctdb_dbid_map_old *dbmap, TALLOC_CTX *mem_ctx) -{ - unsigned int i, j, db; - int ret; - struct ctdb_dbid_map_old *remote_dbmap; - - /* verify that all other nodes have all our databases */ - for (j=0; jnum; j++) { - /* we don't need to ourself ourselves */ - if (nodemap->nodes[j].pnn == pnn) { - continue; - } - /* don't check nodes that are unavailable */ - if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) { - continue; - } - - ret = ctdb_ctrl_getdbmap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn, - mem_ctx, &remote_dbmap); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to get dbids from node %u\n", pnn)); - return -1; - } - - /* step through all local databases */ - for (db=0; dbnum;db++) { - const char *name; - - - for (i=0;inum;i++) { - if (dbmap->dbs[db].db_id == remote_dbmap->dbs[i].db_id) { - break; - } - } - /* the remote node already have this database */ - if (i!=remote_dbmap->num) { - continue; - } - /* ok so we need to create this database */ - ret = ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), pnn, - dbmap->dbs[db].db_id, mem_ctx, - &name); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n", pnn)); - return -1; - } - ret = ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), - nodemap->nodes[j].pnn, - mem_ctx, name, - dbmap->dbs[db].flags, NULL); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to create remote db:%s\n", name)); - return -1; - } - } - } - - return 0; -} - - -/* - ensure we are attached to any databases that anyone else is attached to - */ -static int create_missing_local_databases(struct ctdb_context *ctdb, struct ctdb_node_map_old *nodemap, - uint32_t pnn, struct ctdb_dbid_map_old **dbmap, TALLOC_CTX *mem_ctx) -{ - unsigned int i, j, db; - int ret; - struct ctdb_dbid_map_old *remote_dbmap; - - /* verify that we have all database any other node has */ - for (j=0; jnum; j++) { - /* we don't need to ourself ourselves */ - if (nodemap->nodes[j].pnn == pnn) { - continue; - } - /* don't check nodes that are unavailable */ - if (nodemap->nodes[j].flags & NODE_FLAGS_INACTIVE) { - continue; - } - - ret = ctdb_ctrl_getdbmap(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn, - mem_ctx, &remote_dbmap); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to get dbids from node %u\n", pnn)); - return -1; - } - - /* step through all databases on the remote node */ - for (db=0; dbnum;db++) { - const char *name; - - for (i=0;i<(*dbmap)->num;i++) { - if (remote_dbmap->dbs[db].db_id == (*dbmap)->dbs[i].db_id) { - break; - } - } - /* we already have this db locally */ - if (i!=(*dbmap)->num) { - continue; - } - /* ok so we need to create this database and - rebuild dbmap - */ - ctdb_ctrl_getdbname(ctdb, CONTROL_TIMEOUT(), nodemap->nodes[j].pnn, - remote_dbmap->dbs[db].db_id, mem_ctx, &name); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to get dbname from node %u\n", - nodemap->nodes[j].pnn)); - return -1; - } - ctdb_ctrl_createdb(ctdb, CONTROL_TIMEOUT(), pnn, - mem_ctx, name, - remote_dbmap->dbs[db].flags, NULL); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to create local db:%s\n", name)); - return -1; - } - ret = ctdb_ctrl_getdbmap(ctdb, CONTROL_TIMEOUT(), pnn, mem_ctx, dbmap); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to reread dbmap on node %u\n", pnn)); - return -1; - } - } - } - - return 0; -} - /* update flags on all active nodes */ @@ -1165,7 +1031,6 @@ static int do_recovery(struct ctdb_recoverd *rec, struct ctdb_context *ctdb = rec->ctdb; unsigned int i; int ret; - struct ctdb_dbid_map_old *dbmap; bool self_ban; DEBUG(DEBUG_NOTICE, (__location__ " Starting do_recovery\n")); @@ -1245,32 +1110,6 @@ static int do_recovery(struct ctdb_recoverd *rec, DEBUG(DEBUG_NOTICE, (__location__ " Recovery initiated due to problem with node %u\n", rec->last_culprit_node)); - /* get a list of all databases */ - ret = ctdb_ctrl_getdbmap(ctdb, CONTROL_TIMEOUT(), pnn, mem_ctx, &dbmap); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to get dbids from node :%u\n", pnn)); - goto fail; - } - - /* we do the db creation before we set the recovery mode, so the freeze happens - on all databases we will be dealing with. */ - - /* verify that we have all the databases any other node has */ - ret = create_missing_local_databases(ctdb, nodemap, pnn, &dbmap, mem_ctx); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to create missing local databases\n")); - goto fail; - } - - /* verify that all other nodes have all our databases */ - ret = create_missing_remote_databases(ctdb, nodemap, pnn, dbmap, mem_ctx); - if (ret != 0) { - DEBUG(DEBUG_ERR, (__location__ " Unable to create missing remote databases\n")); - goto fail; - } - DEBUG(DEBUG_NOTICE, (__location__ " Recovery - created remote databases\n")); - - /* Retrieve capabilities from all connected nodes */ ret = update_capabilities(rec, nodemap); if (ret!=0) {