/* 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("[ ][cach] incompatible cache database detected, purging\n");
+ kr_log_info("[cache] incompatible cache database detected, purging\n");
if (oldret) {
- kr_log_verbose("bad ret: %d\n", oldret);
+ kr_log_verbose("[cache] reading version returned: %d\n", oldret);
} else if (val.len != sizeof(CACHE_VERSION)) {
- kr_log_verbose("bad length: %d\n", (int)val.len);
+ kr_log_verbose("[cache] version has bad length: %d\n", (int)val.len);
} else {
uint16_t ver;
memcpy(&ver, val.data, sizeof(ver));
- kr_log_verbose("bad version: %d\n", (int)ver);
+ kr_log_verbose("[cache] version has bad value: %d instead of %d\n",
+ (int)ver, (int)CACHE_VERSION);
}
ret = cache_op(cache, clear);
}
opts2.maxsize = 0;
ret = cache->api->open(&cache->db, &cache->stats, &opts2, mm);
}
+
+ char *fpath;
+ if (asprintf(&fpath, "%s/data.mdb", opts->path) > 0) {
+ kr_cache_emergency_file_to_remove = fpath;
+ } else {
+ assert(false); /* non-critical, but still */
+ fpath = "<ENOMEM>";
+ }
+
if (ret == 0 && opts->maxsize) {
size_t maxsize = cache->api->get_maxsize(cache->db);
if (maxsize > opts->maxsize) kr_log_info(
- "[cache] Warning: cache size %zu instead of %zu."
- " To reduce the size you need to remove the file by hand.\n",
- maxsize, opts->maxsize);
+ "[cache] Warning: real cache size is %zu instead of the requested %zu bytes."
+ " To reduce the size you need to remove the file '%s' by hand.\n",
+ maxsize, opts->maxsize, fpath);
}
if (ret != 0) {
return ret;
cache->ttl_min = KR_CACHE_DEFAULT_TTL_MIN;
cache->ttl_max = KR_CACHE_DEFAULT_TTL_MAX;
kr_cache_make_checkpoint(cache);
-
- char *fpath;
- ret = asprintf(&fpath, "%s/data.mdb", opts->path);
- if (ret > 0) {
- kr_cache_emergency_file_to_remove = fpath;
- } else {
- assert(false); /* non-critical, but still */
- }
return 0;
}
env->mapsize = info.me_mapsize;
if (env->mapsize != env->st_size) {
- kr_log_info("[cache] suspicious size of cache file: %zu != %zu\n",
- (size_t)env->st_size, env->mapsize);
+ kr_log_info("[cache] suspicious size of cache file '%s'"
+ ": file size %zu != LMDB map size %zu\n",
+ env->mdb_data_path, (size_t)env->st_size, env->mapsize);
}
return kr_ok();
}
* contrary to methods based on mdb_env_info(). */
if (st.st_size == env->st_size)
return kr_ok();
- kr_log_info("[cache] detected file size change by another process: %zu -> %zu\n",
- (size_t)env->st_size, (size_t)st.st_size);
+ kr_log_info("[cache] detected size change (by another instance?) of file '%s'"
+ ": file size %zu -> file size %zu\n",
+ env->mdb_data_path, (size_t)env->st_size, (size_t)st.st_size);
env->st_size = st.st_size; // avoid retrying in cycle even if we fail
return refresh_mapsize(env);
}