ctdbd currently only logs when a new hot key is added. If a key gets
hotter then nothing new is logged.
Log hot key updates when the number of migrations has doubled since
the last time that key was logged.
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
struct ctdb_db_hot_key {
uint32_t count;
TDB_DATA key;
+ uint32_t last_logged_count;
};
struct ctdb_db_context {
if (count <= ctdb_db->hot_keys[i].count) {
return;
}
+ if (count >= (2 * ctdb_db->hot_keys[i].last_logged_count)) {
+ keystr = hex_encode_talloc(ctdb_db,
+ (unsigned char *)key.dptr,
+ key.dsize);
+ D_NOTICE("Updated hot key database=%s key=%s count=%d\n",
+ ctdb_db->db_name,
+ keystr ? keystr : "" ,
+ count);
+ TALLOC_FREE(keystr);
+ ctdb_db->hot_keys[i].last_logged_count = count;
+ }
ctdb_db->hot_keys[i].count = count;
goto sort_keys;
}
keystr ? keystr : "" ,
count);
talloc_free(keystr);
+ ctdb_db->hot_keys[id].last_logged_count = count;
sort_keys:
for (i = 1; i < MAX_HOT_KEYS; i++) {
ctdb_db->hot_keys[i].key.dsize = 0;
}
ctdb_db->hot_keys[i].count = 0;
+ ctdb_db->hot_keys[i].last_logged_count = 0;
}
ZERO_STRUCT(ctdb_db->statistics);