Commit 5bdb2ae3 authored by Sergey Vojtovich's avatar Sergey Vojtovich

Fixup: recreate file on size/n_caches change

In reply to:
If we call it with n_caches > what is in the file, we should flush the old cache and the re-initalize the cache for more files.  This is a likely scenario when we add a new store engine that also wants to use the append_cache in which case n_caches can increase for the same server instance
parent 370474b6
...@@ -507,15 +507,19 @@ int pmem_append_cache_init(PMEM_APPEND_CACHE_DIRECTORY *dir, const char *path, ...@@ -507,15 +507,19 @@ int pmem_append_cache_init(PMEM_APPEND_CACHE_DIRECTORY *dir, const char *path,
{ {
if (!pmem_append_cache_open(dir, path)) if (!pmem_append_cache_open(dir, path))
{ {
if (dir->header->n_caches >= n_caches) if (!pmem_append_cache_flush(dir))
{ {
if (!pmem_append_cache_flush(dir)) if (dir->header->n_caches == n_caches && dir->mapped_length == size)
return 0; return 0;
pmem_append_cache_close(dir);
my_delete(path, MYF(0));
goto create;
} }
pmem_append_cache_close(dir); pmem_append_cache_close(dir);
} }
return -1; return -1;
} }
create:
return create_directory(dir, path, size, n_caches); return create_directory(dir, path, size, n_caches);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment