paraoid check for empty db on attach
authorAndrew Tridgell <tridge@samba.org>
Fri, 25 May 2007 08:48:49 +0000 (18:48 +1000)
committerAndrew Tridgell <tridge@samba.org>
Fri, 25 May 2007 08:48:49 +0000 (18:48 +1000)
(This used to be ctdb commit f46ecc15d8d6520a7bce721d915897deba84a54f)

ctdb/common/ctdb_ltdb.c

index caa538ffc1c97a5e39497959606573d7d4ea56c6..501d89a38b41aa961340b41bf48f60a5c0db2e78 100644 (file)
@@ -317,6 +317,20 @@ int ctdb_ltdb_lock_fetch_requeue(struct ctdb_db_context *ctdb_db,
 }
 
 
+/*
+  paraoid check to see if the db is empty
+ */
+static void ctdb_check_db_empty(struct ctdb_db_context *ctdb_db)
+{
+       struct tdb_context *tdb = ctdb_db->ltdb->tdb;
+       int count = tdb_traverse_read(tdb, NULL, NULL);
+       if (count != 0) {
+               DEBUG(0,(__location__ " tdb '%s' not empty on attach! aborting\n",
+                        ctdb_db->db_path));
+               ctdb_fatal(ctdb_db->ctdb, "database not empty on attach");
+       }
+}
+
 /*
   a client has asked to attach a new database
  */
@@ -384,6 +398,8 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
                return -1;
        }
 
+       ctdb_check_db_empty(ctdb_db);
+
        DLIST_ADD(ctdb->db_list, ctdb_db);
 
        /*