DEBUG: Add checks for and print debug messages when 1) a database contains very many...
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 21 May 2012 03:11:38 +0000 (13:11 +1000)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Mon, 21 May 2012 03:26:13 +0000 (13:26 +1000)
Add tunables to control when to log these instances and allow it to be completely turned off by setting the threshold to 0

(This used to be ctdb commit 9ed58fef4991725f75509433496f4d5ffae0ae87)

ctdb/include/ctdb_private.h
ctdb/server/ctdb_recover.c
ctdb/server/ctdb_tunables.c

index a1b4b897180c432eafe7998c4ddc3da135bb0972..0f494b4b2b0f1d196f9a2ea91cf893b1c7b23f17 100644 (file)
@@ -131,6 +131,9 @@ struct ctdb_tunable {
        uint32_t sticky_duration;
        uint32_t sticky_pindown;
        uint32_t no_ip_takeover;
+       uint32_t db_record_count_warn;
+       uint32_t db_record_size_warn;
+       uint32_t db_size_warn;
 };
 
 /*
index 15e9f03b73a607b94cf8652aed1eef47f2991a82..05f72f90dbbfce1f69c1870627979f78c583e039 100644 (file)
@@ -345,6 +345,7 @@ ctdb_control_reload_nodes_file(struct ctdb_context *ctdb, uint32_t opcode)
  */
 struct pulldb_data {
        struct ctdb_context *ctdb;
+       struct ctdb_db_context *ctdb_db;
        struct ctdb_marshall_buffer *pulldata;
        uint32_t len;
        bool failed;
@@ -354,6 +355,8 @@ static int traverse_pulldb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
 {
        struct pulldb_data *params = (struct pulldb_data *)p;
        struct ctdb_rec_data *rec;
+       struct ctdb_context *ctdb = params->ctdb;
+       struct ctdb_db_context *ctdb_db = params->ctdb_db;
 
        /* add the record to the blob */
        rec = ctdb_marshall_record(params->pulldata, 0, key, NULL, data);
@@ -369,6 +372,11 @@ static int traverse_pulldb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
        params->pulldata->count++;
        memcpy(params->len+(uint8_t *)params->pulldata, rec, rec->length);
        params->len += rec->length;
+
+       if (ctdb->tunable.db_record_size_warn != 0 && rec->length > ctdb->tunable.db_record_size_warn) {
+               DEBUG(DEBUG_ERR,("Data record in %s is big. Record size is %d bytes\n", ctdb_db->db_name, (int)rec->length));
+       }
+
        talloc_free(rec);
 
        return 0;
@@ -403,6 +411,7 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT
        reply->db_id = pull->db_id;
 
        params.ctdb = ctdb;
+       params.ctdb_db = ctdb_db;
        params.pulldata = reply;
        params.len = offsetof(struct ctdb_marshall_buffer, data);
        params.failed = false;
@@ -430,6 +439,14 @@ int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DAT
        outdata->dptr = (uint8_t *)params.pulldata;
        outdata->dsize = params.len;
 
+       if (ctdb->tunable.db_record_count_warn != 0 && params.pulldata->count > ctdb->tunable.db_record_count_warn) {
+               DEBUG(DEBUG_ERR,("Database %s is big. Contains %d records\n", ctdb_db->db_name, params.pulldata->count));
+       }
+       if (ctdb->tunable.db_size_warn != 0 && outdata->dsize > ctdb->tunable.db_size_warn) {
+               DEBUG(DEBUG_ERR,("Database %s is big. Contains %d bytes\n", ctdb_db->db_name, (int)outdata->dsize));
+       }
+
+
        return 0;
 }
 
index 5103cc2b6a322ef3474a27f39b1b493d929b3c4c..663c38771f38e2ce5b53f7aaa5baf3d88b142685 100644 (file)
@@ -79,7 +79,10 @@ static const struct {
        { "HopcountMakeSticky",   50,  offsetof(struct ctdb_tunable, hopcount_make_sticky) },
        { "StickyDuration",      600,  offsetof(struct ctdb_tunable, sticky_duration) },
        { "StickyPindown",       200,  offsetof(struct ctdb_tunable, sticky_pindown) },
-       { "NoIPTakeover",         0,  offsetof(struct ctdb_tunable, no_ip_takeover), false }
+       { "NoIPTakeover",         0,  offsetof(struct ctdb_tunable, no_ip_takeover), false },
+       { "DBRecordCountWarn",    100000,  offsetof(struct ctdb_tunable, db_record_count_warn), false },
+       { "DBRecordSizeWarn",   10000000,  offsetof(struct ctdb_tunable, db_record_size_warn), false },
+       { "DBSizeWarn",        100000000,  offsetof(struct ctdb_tunable, db_size_warn), false }
 };
 
 /*