From 7362e1c3efb8781e879e11ef1914a7d78dc862b2 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Tue, 7 Jul 2026 15:00:52 +0200 Subject: [PATCH] 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. --- NEWS | 4 ++++ lib/cache/cdb_lmdb.c | 11 +++++++++++ 2 files changed, 15 insertions(+) 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; -- 2.47.3