microsoft/garnet · error · TsavoriteException
Read Cache Log Memory size or PageCount must be specified
Error message
Read Cache Log Memory size or PageCount must be specified
What it means
Mirror of error 186 but for the read cache: when read cache is enabled, Tsavorite needs either a memory budget (ReadCacheMemorySize) or an explicit page count (ReadCachePageCount) to size the read-cache log. If ReadCacheMemorySize is 0/unset and ReadCachePageCount is 0, GetSettings throws TsavoriteException because it cannot size the read cache.
Source
Thrown at libs/server/Servers/GarnetServerOptions.cs:783
kvSettings.ReadCachePageCount = ReadCachePageCount;
kvSettings.ReadCachePageSize = 1L << ReadCachePageSizeBits();
kvSettings.ReadCacheMemorySize = ParseSize(ReadCacheMemorySize, out _);
if (kvSettings.ReadCacheMemorySize > 0)
{
var pageCount = kvSettings.ReadCacheMemorySize / kvSettings.ReadCachePageSize;
if (kvSettings.PageCount > pageCount)
logger?.LogInformation("[Store] Warning: Read cache overriding specified PageCount of {kvSettingsReadCachePageCount} with smaller page count calculated from LogMemorySize limit divided by PageSize: {pageCount}", kvSettings.ReadCachePageCount, pageCount);
var bufferSize = NextPowerOf2(pageCount);
logger?.LogInformation("[Store] Read cache enabled with {LogPages} log pages in memory, of which {pageCount} are initially allocated", PrettySize(bufferSize), pageCount);
logger?.LogInformation("[Store] Read cache Log memory size limit of {LogMemorySize} will be enforced", PrettySize(kvSettings.ReadCacheMemorySize));
}
else
{
if (kvSettings.ReadCachePageCount == 0)
throw new TsavoriteException($"Read Cache Log Memory size or PageCount must be specified");
var bufferSize = (int)NextPowerOf2(kvSettings.ReadCachePageCount);
if (kvSettings.PageCount < bufferSize)
{
logger?.LogInformation("[Store] Warning: Read cache overriding specified PageCount of {kvSettingsReadCachePageCount} with next power of 2 page count {bufferSize}", kvSettings.ReadCachePageCount, bufferSize);
kvSettings.PageCount = bufferSize;
}
logger?.LogInformation("[Store] Read cache enabled with {LogPages} log pages in memory, all of which will be used because there is no MemorySize limit", PrettySize(bufferSize));
logger?.LogInformation("[Store] No Read cache log memory size limit will be enforced");
}
}
if (EnableStorageTier)
{
if (LogDir is null or "")
LogDir = Directory.GetCurrentDirectory();
logFactory = GetInitializedDeviceFactory(LogDir);
// These must match GetInitializedSegmentFileDevice.GetStoreHLogDeviceView on GitHub (pinned to 951b0fc683)
Solutions
- Specify a read-cache memory budget, e.g. --readcache-memory 1g.
- Or specify a page count, e.g. --readcache-pagecount 256.
- When embedding, set kvSettings.ReadCacheMemorySize or kvSettings.ReadCachePageCount when enabling the read cache.
Example fix
# before (fails) garnet-server --storage-tier --logdir /data --readcache # after garnet-server --storage-tier --logdir /data --readcache --readcache-memory 1g
Defensive patterns
Strategy: validation
Validate before calling
if (options.EnableReadCache && kvSettings.ReadCacheMemorySize <= 0 && kvSettings.ReadCachePageCount == 0) {
throw new InvalidOperationException("Read cache requires ReadCacheMemorySize or ReadCachePageCount");
} Prevention
- When enabling the read cache, always set --readcache-memory or --readcache-pagecount.
- Embedding? Set KVSettings.ReadCacheMemorySize or KVSettings.ReadCachePageCount.
When it happens
Trigger: Enabling --readcache without --readcache-memory and without --readcache-pagecount. Thrown at GarnetServerOptions.cs:782-783.
Common situations: Enabling the read cache flag but stripping the memory size in a custom launcher; config templating that clears ReadCacheMemorySize.
Related errors
- MutablePercent must be between 10 and 95
- Store Log Memory size or PageCount must be specified
- Index size {IndexMemorySize} should not be less than index m
- Read cache requires storage tiering to be enabled
- MaxInlineKeySize value '{MaxInlineKeySize}' ({sizeInBytes} b
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/82ecf7fba8ae7ab4.
Report an issue: GitHub.