From: Vladimír Čunát Date: Tue, 7 Jul 2026 13:00:52 +0000 (+0200) Subject: lib/cache/cdb: deal with LMDB 1.0.0 switching format X-Git-Tag: v5.7.8~2^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7362e1c3;p=thirdparty%2Fknot-resolver.git lib/cache/cdb: deal with LMDB 1.0.0 switching format 1.0.0 also regresses in properties of mdb_drop() (which will be fixed in 1.0.1 reportedly), but with kresd 5.x this doesn't seem to cause issues. --- diff --git a/NEWS b/NEWS index 70313a13b..9acfc0a80 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,10 @@ Bugfixes -------- - cache: avoid excessive logging introduced in the last release (!1871) +Improvements +------------ +- cache: deal with LMDB 1.0.0 switching format (!1872) + Knot Resolver 5.7.7 (2026-07-22) ================================ diff --git a/lib/cache/cdb_lmdb.c b/lib/cache/cdb_lmdb.c index 80c73729e..f2c87253a 100644 --- a/lib/cache/cdb_lmdb.c +++ b/lib/cache/cdb_lmdb.c @@ -425,6 +425,17 @@ static int cdb_init(kr_cdb_pt *db, struct kr_cdb_stats *stats, return kr_error(ENOMEM); } int ret = cdb_open_env(env, opts->path, opts->maxsize, stats); + /* Uh, LMDB 1.0 is incompatible with LMDB 0.y. Hack-retry. */ + if (abs(ret) == abs(MDB_INVALID)) { + kr_log_error(CACHE, "found incompatible data after LMDB version change, probably; " + "clearing and retrying\n"); + auto_free char *mdb_datafile = kr_strcatdup(2, opts->path, "/data.mdb"); + auto_free char *mdb_lockfile = kr_strcatdup(2, opts->path, "/lock.mdb"); + unlink(mdb_datafile); /* we ignore errors; e.g. either might not exist */ + unlink(mdb_lockfile); + + ret = cdb_open_env(env, opts->path, opts->maxsize, stats); + } if (ret != 0) { free(env); return ret;