From: Ronnie Sahlberg Date: Sat, 5 May 2007 19:53:15 +0000 (+1000) Subject: add support in catdb to dump the content of a specific nodes tdb instead X-Git-Tag: tevent-0.9.20~348^2~2768^2~21 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7bbcc964f25ef469942c59428893a1ec4f3df1be;p=thirdparty%2Fsamba.git add support in catdb to dump the content of a specific nodes tdb instead of traversing the full cluster. this makes it easier to debug recovery update the test script for recovery to reflect the newish signatures to ctdb_control the catdb control does still segfault however when there are missing nodes in the cluster as there are toward the end of the recovery test (This used to be ctdb commit 8de2a97c14a444f817ceb36461314f10c9601ecc) --- diff --git a/ctdb/tests/recover.sh b/ctdb/tests/recover.sh index 3267699ffde..09d35114c01 100755 --- a/ctdb/tests/recover.sh +++ b/ctdb/tests/recover.sh @@ -26,14 +26,13 @@ echo echo echo "Printing all databases on all nodes. they should all be empty" echo "=============================================================" -bin/ctdb_control --socket=/tmp/ctdb.socket getdbmap 0 | egrep "^dbid:" | sed -e "s/^dbid://" -e "s/ .*$//" | while read DB; do +bin/ctdb_control --socket=/tmp/ctdb.socket getdbmap 0 | egrep "^dbid:" | sed -e "s/^.*name://" -e "s/ .*$//" | while read DBNAME; do seq 0 3 | while read NODE; do - echo "Content of DB:$DB NODE:$NODE :" - bin/ctdb_control --socket=/tmp/ctdb.socket catdb $NODE $DB + echo "Content of DBNAME:$DBNAME NODE:$NODE :" + bin/ctdb_control --socket=/tmp/ctdb.socket catdb $DBNAME $NODE done done - echo echo echo "Populating the databases" @@ -60,10 +59,10 @@ echo echo echo "Printing all databases on all nodes. there should be a record there" echo "=============================================================" -bin/ctdb_control --socket=/tmp/ctdb.socket getdbmap 0 | egrep "^dbid:" | sed -e "s/^dbid://" -e "s/ .*$//" | while read DB; do +bin/ctdb_control --socket=/tmp/ctdb.socket getdbmap 0 | egrep "^dbid:" | sed -e "s/^.*name://" -e "s/ .*$//" | while read DBNAME; do seq 0 3 | while read NODE; do - echo "Content of DB:$DB NODE:$NODE :" - bin/ctdb_control --socket=/tmp/ctdb.socket catdb $NODE $DB + echo "Content of DBNAME:$DBNAME NODE:$NODE :" + bin/ctdb_control --socket=/tmp/ctdb.socket catdb $DBNAME $NODE done done @@ -88,14 +87,18 @@ echo "The databases should be the same now on all nodes" echo "and the record will have been migrated to node 0" echo "=================================================" echo "Node 1:" -bin/ctdb_control --socket=/tmp/ctdb.socket catdb 1 0x220c2a7b +bin/ctdb_control --socket=/tmp/ctdb.socket catdb test4.tdb 1 echo "Node 2:" -bin/ctdb_control --socket=/tmp/ctdb.socket catdb 2 0x220c2a7b +bin/ctdb_control --socket=/tmp/ctdb.socket catdb test4.tdb 2 echo "Node 3:" -bin/ctdb_control --socket=/tmp/ctdb.socket catdb 3 0x220c2a7b +bin/ctdb_control --socket=/tmp/ctdb.socket catdb test4.tdb 3 echo "nodemap:" bin/ctdb_control --socket=/tmp/ctdb.socket getnodemap 3 +echo +echo +echo "Traverse the cluster and dump the database" +bin/ctdb_control --socket=/tmp/ctdb.socket catdb test4.tdb #leave the ctdb daemons running so one can look at the box in more detail diff --git a/ctdb/tools/ctdb_control.c b/ctdb/tools/ctdb_control.c index d35645aef2f..a6d8181ffbc 100644 --- a/ctdb/tools/ctdb_control.c +++ b/ctdb/tools/ctdb_control.c @@ -46,7 +46,7 @@ static void usage(void) " getdbmap lists databases on a node\n" " getnodemap lists nodes known to a ctdb daemon\n" " createdb create a database\n" - " catdb lists all keys/data in a db\n" + " catdb [vnn] lists all keys/data in a db\n" " cpdb lists all keys in a remote tdb\n" " setdmaster sets new dmaster for all records in the database\n" " cleardb deletes all records in a db\n" @@ -347,9 +347,11 @@ static int control_recover(struct ctdb_context *ctdb, int argc, const char **arg } for (i=0;inum;i++) { const char *path; + const char *name; ctdb_ctrl_getdbpath(ctdb, timeval_current_ofs(1, 0), CTDB_CURRENT_NODE, dbmap->dbids[i], ctdb, &path); - printf("dbid:0x%08x path:%s\n", dbmap->dbids[i], path); + ctdb_ctrl_getdbname(ctdb, timeval_current_ofs(1, 0), CTDB_CURRENT_NODE, dbmap->dbids[i], ctdb, &name); + printf("dbid:0x%08x name:%s path:%s\n", dbmap->dbids[i], name, path); } /* 5: pull all records from all other nodes across to this node @@ -586,6 +588,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv) { const char *db_name; struct ctdb_db_context *ctdb_db; + uint32_t vnn; int ret; if (argc < 1) { @@ -599,12 +602,35 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv) return -1; } - ret = ctdb_dump_db(ctdb_db, stdout); - if (ret == -1) { - printf("Unable to dump database\n"); - return -1; - } + if (argc==1) { + /* traverse and dump the cluster tdb */ + ret = ctdb_dump_db(ctdb_db, stdout); + if (ret == -1) { + printf("Unable to dump database\n"); + return -1; + } + } else { + struct ctdb_key_list keys; + int i; + /* dump only the local tdb of a specific node */ + vnn = strtoul(argv[1], NULL, 0); + ret = ctdb_ctrl_pulldb(ctdb, vnn, ctdb_db->db_id, CTDB_LMASTER_ANY, ctdb, &keys); + if (ret == -1) { + printf("Unable to pull remote database\n"); + return -1; + } + for(i=0;inum); for(i=0;inum;i++){ const char *path; + const char *name; ctdb_ctrl_getdbpath(ctdb, timeval_current_ofs(1, 0), CTDB_CURRENT_NODE, dbmap->dbids[i], ctdb, &path); - printf("dbid:0x%08x path:%s\n", dbmap->dbids[i], path); + ctdb_ctrl_getdbname(ctdb, timeval_current_ofs(1, 0), CTDB_CURRENT_NODE, dbmap->dbids[i], ctdb, &name); + printf("dbid:0x%08x name:%s path:%s\n", dbmap->dbids[i], name, path); } return 0;