1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

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)
This commit is contained in:
Ronnie Sahlberg 2012-05-21 13:11:38 +10:00
parent dd647d45cb
commit 26322d257d
3 changed files with 24 additions and 1 deletions

View 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;
};
/*

View 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;
}

View 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 }
};
/*