From 26322d257d9e75397c00037f93150be1b5b48df3 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Mon, 21 May 2012 13:11:38 +1000 Subject: [PATCH] DEBUG: Add checks for and print debug messages when 1) a database contains very many records, 2) when a database is very big, 3) when a single record is very big. 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 | 3 +++ ctdb/server/ctdb_recover.c | 17 +++++++++++++++++ ctdb/server/ctdb_tunables.c | 5 ++++- 3 files changed, 24 insertions(+), 1 deletion(-) diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index a1b4b897180..0f494b4b2b0 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -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; }; /* diff --git a/ctdb/server/ctdb_recover.c b/ctdb/server/ctdb_recover.c index 15e9f03b73a..05f72f90dbb 100644 --- a/ctdb/server/ctdb_recover.c +++ b/ctdb/server/ctdb_recover.c @@ -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; } diff --git a/ctdb/server/ctdb_tunables.c b/ctdb/server/ctdb_tunables.c index 5103cc2b6a3..663c38771f3 100644 --- a/ctdb/server/ctdb_tunables.c +++ b/ctdb/server/ctdb_tunables.c @@ -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 } }; /* -- 2.34.1