tools/ctdb: Remove setdbseqnum command
authorAmitay Isaacs <amitay@gmail.com>
Tue, 24 Sep 2013 03:10:31 +0000 (13:10 +1000)
committerAmitay Isaacs <amitay@gmail.com>
Fri, 4 Oct 2013 05:47:11 +0000 (15:47 +1000)
This command was added to test persistent database recovery with sequence
numbers.  With the new persistent transaction code, sequence numbers get
updated automatically, so there is no need for this command.

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
(This used to be ctdb commit 14bfd22fad1a5fd27eede1be7fccbaed9466e13e)

ctdb/tools/ctdb.c

index 727d38e051f9590c268bd2a92d2f23cc42e6dcf8..bad09c9c42ec6c4b7ae3648b11c648b52f3ff656 100644 (file)
@@ -5111,91 +5111,6 @@ static int control_getdbseqnum(struct ctdb_context *ctdb, int argc, const char *
        return 0;
 }
 
-/*
- * set db seqnum
- */
-static int control_setdbseqnum(struct ctdb_context *ctdb, int argc, const char **argv)
-{
-       int ret;
-       struct ctdb_db_context *ctdb_db;
-       uint32_t db_id;
-       uint8_t flags;
-       uint64_t old_seqnum, new_seqnum;
-       TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
-       struct ctdb_transaction_handle *h;
-       TDB_DATA key, data;
-       bool persistent;
-
-       if (argc != 2) {
-               talloc_free(tmp_ctx);
-               usage();
-       }
-
-       if (!db_exists(ctdb, argv[0], &db_id, &flags)) {
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       persistent = flags & CTDB_DB_FLAGS_PERSISTENT;
-       if (!persistent) {
-               DEBUG(DEBUG_ERR,("Database '%s' is not persistent\n", argv[0]));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       ret = ctdb_ctrl_getdbseqnum(ctdb, TIMELIMIT(), options.pnn, db_id, &old_seqnum);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR, ("Unable to get seqnum from node."));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       new_seqnum = strtoull(argv[1], NULL, 0);
-       if (new_seqnum <= old_seqnum) {
-               DEBUG(DEBUG_ERR, ("New sequence number is less than current sequence number\n"));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       ctdb_db = ctdb_attach(ctdb, TIMELIMIT(), argv[0], persistent, 0);
-       if (ctdb_db == NULL) {
-               DEBUG(DEBUG_ERR,("Unable to attach to database '%s'\n", argv[0]));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       h = ctdb_transaction_start(ctdb_db, tmp_ctx);
-       if (h == NULL) {
-               DEBUG(DEBUG_ERR,("Failed to start transaction on database %s\n", argv[0]));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       key.dptr  = (uint8_t *)discard_const(CTDB_DB_SEQNUM_KEY);
-       key.dsize = strlen(CTDB_DB_SEQNUM_KEY) + 1;
-
-       data.dsize = sizeof(new_seqnum);
-       data.dptr = talloc_size(tmp_ctx, data.dsize);
-       *data.dptr = new_seqnum;
-
-       ret = ctdb_transaction_store(h, key, data);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,("Failed to store record\n"));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       ret = ctdb_transaction_commit(h);
-       if (ret != 0) {
-               DEBUG(DEBUG_ERR,("Failed to commit transaction\n"));
-               talloc_free(tmp_ctx);
-               return -1;
-       }
-
-       talloc_free(tmp_ctx);
-       return 0;
-}
-
 /*
   run an eventscript on a node
  */
@@ -6175,7 +6090,6 @@ static const struct {
        { "checktcpport",    control_chktcpport,        false,  true,  "check if a service is bound to a specific tcp port or not", "<port>" },
        { "rebalancenode",     control_rebalancenode,   false,  false, "mark nodes as forced IP rebalancing targets", "[<pnn-list>]"},
        { "getdbseqnum",     control_getdbseqnum,       false,  false, "get the sequence number off a database", "<dbname|dbid>" },
-       { "setdbseqnum",     control_setdbseqnum,       false,  false, "set the sequence number for a database", "<dbname|dbid> <seqnum>" },
        { "nodestatus",      control_nodestatus,        true,   false,  "show and return node status", "[<pnn-list>]" },
        { "dbstatistics",    control_dbstatistics,      false,  false, "show db statistics", "<dbname|dbid>" },
        { "reloadips",       control_reloadips,         false,  false, "reload the public addresses file on specified nodes" , "[<pnn-list>]" },