diff options
author | Vladimír Čunát <vladimir.cunat@nic.cz> | 2020-08-24 18:01:59 +0200 |
---|---|---|
committer | Petr Špaček <petr.spacek@nic.cz> | 2020-09-07 17:47:46 +0200 |
commit | 64b22c321e2dfb2fd23f09a7030f3348f30023e9 (patch) | |
tree | 53110489709f115eebb7a57e4839fdeb8cfeb14c /utils/cache_gc | |
parent | utils/cache_gc nitpick: print time in milliseconds (diff) | |
download | knot-resolver-64b22c321e2dfb2fd23f09a7030f3348f30023e9.tar.xz knot-resolver-64b22c321e2dfb2fd23f09a7030f3348f30023e9.zip |
utils/cache_gc nitpick: more precise error prints
Diffstat (limited to 'utils/cache_gc')
-rw-r--r-- | utils/cache_gc/db.c | 9 | ||||
-rw-r--r-- | utils/cache_gc/db.h | 6 | ||||
-rw-r--r-- | utils/cache_gc/kr_cache_gc.c | 7 |
3 files changed, 19 insertions, 3 deletions
diff --git a/utils/cache_gc/db.c b/utils/cache_gc/db.c index c71fabf6..3a853b43 100644 --- a/utils/cache_gc/db.c +++ b/utils/cache_gc/db.c @@ -179,12 +179,15 @@ int kr_gc_cache_iter(knot_db_t * knot_db, const kr_cache_gc_cfg_t *cfg, return ret; } - it = api->iter_begin(&txn, KNOT_DB_FIRST); + it = api->iter_begin(&txn, KNOT_DB_NOOP); // _FIRST is split for easier debugging if (it == NULL) { - printf("Error iterating database.\n"); + printf("Error: failed to create an iterator.\n"); api->txn_abort(&txn); return KNOT_ERROR; } + it = api->iter_seek(it, NULL, KNOT_DB_FIRST); + if (it == NULL) + printf("Suspicious: completely empty LMDB at this moment?\n"); int txn_steps = 0; while (it != NULL) { @@ -267,7 +270,7 @@ int kr_gc_cache_iter(knot_db_t * knot_db, const kr_cache_gc_cfg_t *cfg, } it = api->iter_begin(&txn, KNOT_DB_NOOP); if (it == NULL) { - printf("Error iterating database.\n"); + printf("Error: failed to create an iterator.\n"); api->txn_abort(&txn); return KNOT_ERROR; } diff --git a/utils/cache_gc/db.h b/utils/cache_gc/db.h index 44cfbec2..0e20df19 100644 --- a/utils/cache_gc/db.h +++ b/utils/cache_gc/db.h @@ -22,3 +22,9 @@ int kr_gc_cache_iter(knot_db_t * knot_db, const kr_cache_gc_cfg_t *cfg, kr_gc_iter_callback callback, void *ctx); const uint16_t *kr_gc_key_consistent(knot_db_val_t key); + +#ifdef DEBUG +/** Printf a *binary* string in a human-readable way. */ +void debug_printbin(const char *str, unsigned int len); +#endif + diff --git a/utils/cache_gc/kr_cache_gc.c b/utils/cache_gc/kr_cache_gc.c index 1308c75e..5aae95f0 100644 --- a/utils/cache_gc/kr_cache_gc.c +++ b/utils/cache_gc/kr_cache_gc.c @@ -281,6 +281,13 @@ int kr_cache_gc(kr_cache_gc_cfg_t *cfg, kr_cache_gc_state_t **state) break; case KNOT_ENOENT: already_gone++; +#ifdef DEBUG + // kresd normally only inserts (or overwrites), + // so it's generally suspicious when a key goes missing. + printf("Record already gone (key len %zu): ", (*i)->len); + debug_printbin((*i)->data, (*i)->len); + printf("\n"); +#endif break; case KNOT_ESPACE: printf("Warning: out of space, bailing out to retry later.\n"); |