Merge remote-tracking branch 'public/bug11737_diagnostic'

This commit is contained in:
Nick Mathewson 2014-05-07 22:52:44 -04:00
commit 683b80bf81
2 changed files with 17 additions and 6 deletions

View File

@ -0,0 +1,5 @@
o Minor features (diagnostic):
- When logging a warning because of bug #7164, additionally check the
hash table for consistency (as proposed on ticket #11737). This may
help diagnose bug #7164.

View File

@ -386,18 +386,21 @@ microdesc_cache_clean(microdesc_cache_t *cache, time_t cutoff, int force)
smartlist_t *nodes = nodelist_find_nodes_with_microdesc(*mdp); smartlist_t *nodes = nodelist_find_nodes_with_microdesc(*mdp);
const networkstatus_t *ns = networkstatus_get_latest_consensus(); const networkstatus_t *ns = networkstatus_get_latest_consensus();
long networkstatus_age = -1; long networkstatus_age = -1;
const int ht_badness = HT_REP_IS_BAD_(microdesc_map, &cache->map);
if (ns) { if (ns) {
networkstatus_age = now - ns->valid_after; networkstatus_age = now - ns->valid_after;
} }
log_warn(LD_BUG, "Microdescriptor seemed very old " log_warn(LD_BUG, "Microdescriptor seemed very old "
"(last listed %d hours ago vs %d hour cutoff), but is still " "(last listed %d hours ago vs %d hour cutoff), but is still "
"marked as being held by %d node(s). I found %d node(s) " "marked as being held by %d node(s). I found %d node(s) "
"holding it. Current networkstatus is %ld hours old.", "holding it. Current networkstatus is %ld hours old. "
"Hashtable badness is %d.",
(int)((now - (*mdp)->last_listed) / 3600), (int)((now - (*mdp)->last_listed) / 3600),
(int)((now - cutoff) / 3600), (int)((now - cutoff) / 3600),
held_by_nodes, held_by_nodes,
smartlist_len(nodes), smartlist_len(nodes),
networkstatus_age / 3600); networkstatus_age / 3600,
ht_badness);
SMARTLIST_FOREACH_BEGIN(nodes, const node_t *, node) { SMARTLIST_FOREACH_BEGIN(nodes, const node_t *, node) {
const char *rs_match = "No RS"; const char *rs_match = "No RS";
@ -664,8 +667,10 @@ microdesc_free_(microdesc_t *md, const char *fname, int lineno)
tor_fragile_assert(); tor_fragile_assert();
} }
if (md->held_by_nodes) { if (md->held_by_nodes) {
microdesc_cache_t *cache = get_microdesc_cache();
int found=0; int found=0;
const smartlist_t *nodes = nodelist_get_list(); const smartlist_t *nodes = nodelist_get_list();
const int ht_badness = HT_REP_IS_BAD_(microdesc_map, &cache->map);
SMARTLIST_FOREACH(nodes, node_t *, node, { SMARTLIST_FOREACH(nodes, node_t *, node, {
if (node->md == md) { if (node->md == md) {
++found; ++found;
@ -674,12 +679,13 @@ microdesc_free_(microdesc_t *md, const char *fname, int lineno)
}); });
if (found) { if (found) {
log_warn(LD_BUG, "microdesc_free() called from %s:%d, but md was still " log_warn(LD_BUG, "microdesc_free() called from %s:%d, but md was still "
"referenced %d node(s); held_by_nodes == %u", "referenced %d node(s); held_by_nodes == %u, ht_badness == %d",
fname, lineno, found, md->held_by_nodes); fname, lineno, found, md->held_by_nodes, ht_badness);
} else { } else {
log_warn(LD_BUG, "microdesc_free() called from %s:%d with held_by_nodes " log_warn(LD_BUG, "microdesc_free() called from %s:%d with held_by_nodes "
"set to %u, but md was not referenced by any nodes", "set to %u, but md was not referenced by any nodes. "
fname, lineno, md->held_by_nodes); "ht_badness == %d",
fname, lineno, md->held_by_nodes, ht_badness);
} }
tor_fragile_assert(); tor_fragile_assert();
} }