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) {
}
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;
}
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
+
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");