From: Petr Špaček Date: Tue, 22 Aug 2017 16:20:21 +0000 (+0200) Subject: daemon: improve error reporting related to cache configuration X-Git-Tag: v1.4.0~15^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=dce50eff016680ae9a13ee335b8392c5baab16be;p=thirdparty%2Fknot-resolver.git daemon: improve error reporting related to cache configuration Confusion related to wrong cache configuration is more frequent than it should be. Hopefully this will enable users to help themselves. --- diff --git a/daemon/bindings.c b/daemon/bindings.c index 5930f48ae..6eb95e990 100644 --- a/daemon/bindings.c +++ b/daemon/bindings.c @@ -668,8 +668,12 @@ static int cache_open(lua_State *L) }; int ret = kr_cache_open(&engine->resolver.cache, api, &opts, engine->pool); if (ret != 0) { - format_error(L, "can't open cache"); - lua_error(L); + char cwd[PATH_MAX]; + if(getcwd(cwd, sizeof(cwd)) == NULL) { + const char errprefix[] = ""; + strncpy(cwd, errprefix, sizeof(cwd)); + } + return luaL_error(L, "can't open cache path '%s'; working directory '%s'", opts.path, cwd); } /* Store current configuration */ diff --git a/lib/cache.c b/lib/cache.c index c3d793d40..3ab1e66a1 100644 --- a/lib/cache.c +++ b/lib/cache.c @@ -63,7 +63,7 @@ static int assert_right_version(struct kr_cache *cache) /* Version doesn't match. Recreate cache and write version key. */ ret = cache_op(cache, count); if (ret != 0) { /* Non-empty cache, purge it. */ - kr_log_info("[cache] purging cache\n"); + kr_log_info("[cache] incompatible cache database detected, purging\n"); ret = cache_purge(cache); } /* Either purged or empty. */ diff --git a/lib/cdb_lmdb.c b/lib/cdb_lmdb.c index 444abbfea..1161872d3 100644 --- a/lib/cdb_lmdb.c +++ b/lib/cdb_lmdb.c @@ -52,6 +52,7 @@ static int lmdb_error(int error) case ENOSPC: return kr_error(ENOSPC); default: + kr_log_info("[cache] LMDB error: %s\n", mdb_strerror(error)); return -abs(error); } } @@ -220,9 +221,9 @@ static int cdb_init(knot_db_t **db, struct kr_cdb_opts *opts, knot_mm_t *pool) auto_free char *lockfile = kr_strcatdup(2, opts->path, "/.cachelock"); if (lockfile) { if (unlink(lockfile) == 0) { - kr_log_info("[system] cache: cleared stale lockfile '%s'\n", lockfile); + kr_log_info("[cache] cleared stale lockfile '%s'\n", lockfile); } else if (errno != ENOENT) { - kr_log_info("[system] cache: failed to clear stale lockfile '%s': %s\n", lockfile, + kr_log_info("[cache] failed to clear stale lockfile '%s': %s\n", lockfile, strerror(errno)); } }