]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
lib/cache/cdb: deal with LMDB 1.0.0 switching format 1872/head
authorVladimír Čunát <vladimir.cunat@nic.cz>
Tue, 7 Jul 2026 13:00:52 +0000 (15:00 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 3 Aug 2026 10:42:00 +0000 (12:42 +0200)
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
lib/cache/cdb_lmdb.c

diff --git a/NEWS b/NEWS
index 70313a13b0f1f777448e4605f89c2fc31019f9f2..9acfc0a8074df5ce863c04d303e0b6229fed2cec 100644 (file)
--- 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)
 ================================
index 80c73729ea5d548dfbf694490dfb71d85bb929e8..f2c87253ac5f805c4a0b80571491a3544a58a592 100644 (file)
@@ -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;