{"record":{"id":"82ecf7fba8ae7ab4","repo":"microsoft/garnet","slug":"read-cache-log-memory-size-or-pagecount-must-be-sp","errorCode":null,"errorMessage":"Read Cache Log Memory size or PageCount must be specified","messagePattern":"Read Cache Log Memory size or PageCount must be specified","errorType":"validation","errorClass":"TsavoriteException","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":783,"sourceCode":"                    kvSettings.ReadCachePageCount = ReadCachePageCount;\n\n                kvSettings.ReadCachePageSize = 1L << ReadCachePageSizeBits();\n                kvSettings.ReadCacheMemorySize = ParseSize(ReadCacheMemorySize, out _);\n\n                if (kvSettings.ReadCacheMemorySize > 0)\n                {\n                    var pageCount = kvSettings.ReadCacheMemorySize / kvSettings.ReadCachePageSize;\n                    if (kvSettings.PageCount > pageCount)\n                        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);\n\n                    var bufferSize = NextPowerOf2(pageCount);\n                    logger?.LogInformation(\"[Store] Read cache enabled with {LogPages} log pages in memory, of which {pageCount} are initially allocated\", PrettySize(bufferSize), pageCount);\n                    logger?.LogInformation(\"[Store] Read cache Log memory size limit of {LogMemorySize} will be enforced\", PrettySize(kvSettings.ReadCacheMemorySize));\n                }\n                else\n                {\n                    if (kvSettings.ReadCachePageCount == 0)\n                        throw new TsavoriteException($\"Read Cache Log Memory size or PageCount must be specified\");\n                    var bufferSize = (int)NextPowerOf2(kvSettings.ReadCachePageCount);\n                    if (kvSettings.PageCount < bufferSize)\n                    {\n                        logger?.LogInformation(\"[Store] Warning: Read cache overriding specified PageCount of {kvSettingsReadCachePageCount} with next power of 2 page count {bufferSize}\", kvSettings.ReadCachePageCount, bufferSize);\n                        kvSettings.PageCount = bufferSize;\n                    }\n                    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));\n                    logger?.LogInformation(\"[Store] No Read cache log memory size limit will be enforced\");\n                }\n            }\n\n            if (EnableStorageTier)\n            {\n                if (LogDir is null or \"\")\n                    LogDir = Directory.GetCurrentDirectory();\n                logFactory = GetInitializedDeviceFactory(LogDir);\n\n                // These must match GetInitializedSegmentFileDevice.GetStoreHLogDevice","sourceCodeStart":765,"sourceCodeEnd":801,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L765-L801","documentation":"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.","triggerScenarios":"Enabling --readcache without --readcache-memory and without --readcache-pagecount. Thrown at GarnetServerOptions.cs:782-783.","commonSituations":"Enabling the read cache flag but stripping the memory size in a custom launcher; config templating that clears ReadCacheMemorySize.","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."],"exampleFix":"# before (fails)\ngarnet-server --storage-tier --logdir /data --readcache\n\n# after\ngarnet-server --storage-tier --logdir /data --readcache --readcache-memory 1g","handlingStrategy":"validation","validationCode":"if (options.EnableReadCache && kvSettings.ReadCacheMemorySize <= 0 && kvSettings.ReadCachePageCount == 0) {\n    throw new InvalidOperationException(\"Read cache requires ReadCacheMemorySize or ReadCachePageCount\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["When enabling the read cache, always set --readcache-memory or --readcache-pagecount.","Embedding? Set KVSettings.ReadCacheMemorySize or KVSettings.ReadCachePageCount."],"tags":["garnet","config","storage","read-cache","tsavorite","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}