microsoft/garnet · error · TsavoriteException

Store Log Memory size or PageCount must be specified

Error message

Store Log Memory size or PageCount must be specified

What it means

GetSettings requires the main store to have either a memory budget (LogMemorySize) or an explicit page count (PageCount). If LogMemorySize is 0/unset, the code enters the else-branch and demands kvSettings.PageCount != 0; when both are zero it throws TsavoriteException because Tsavorite cannot size an in-memory log without at least one of them.

Source

Thrown at libs/server/Servers/GarnetServerOptions.cs:712

                kvSettings.PageCount = PageCount;

            logger?.LogInformation("[Store] Using page size of {PageSize}", PrettySize(kvSettings.PageSize));
            logger?.LogInformation("[Store] Each page can hold ~{PageSize} key-value pairs of objects", kvSettings.PageSize / 24);

            if (kvSettings.LogMemorySize > 0)
            {
                var pageCount = kvSettings.LogMemorySize / kvSettings.PageSize;
                if (kvSettings.PageCount > pageCount)
                    logger?.LogInformation("[Store] Warning: overriding specified PageCount of {kvSettingsPageCount} with smaller page count calculated from LogMemorySize limit divided by PageSize: {pageCount}", kvSettings.PageCount, pageCount);

                var bufferSize = NextPowerOf2(pageCount);
                logger?.LogInformation("[Store] There are {LogPages} log pages in memory, of which {pageCount} are initially allocated", PrettySize(bufferSize), pageCount);
                logger?.LogInformation("[Store] Log memory size limit of {LogMemorySize} will be enforced", PrettySize(kvSettings.LogMemorySize));
            }
            else
            {
                if (kvSettings.PageCount == 0)
                    throw new TsavoriteException($"Store Log Memory size or PageCount must be specified");
                var bufferSize = (int)NextPowerOf2(kvSettings.PageCount);
                if (kvSettings.PageCount < bufferSize)
                {
                    logger?.LogInformation("[Store] Warning: overriding specified PageCount of {kvSettingsPageCount} with next power of 2 page count {bufferSize}", kvSettings.PageCount, bufferSize);
                    kvSettings.PageCount = bufferSize;
                }
                logger?.LogInformation("[Store] There are {LogPages} log pages in memory, all of which will be used because there is no MemorySize limit", PrettySize(bufferSize));
                logger?.LogInformation("[Store] No log memory size limit will be enforced");
            }

            kvSettings.SegmentSize = 1L << SegmentSizeBits(isObj: false);
            kvSettings.ObjectLogSegmentSize = 1L << SegmentSizeBits(isObj: true);
            logger?.LogInformation("[Store] Using disk segment size of {SegmentSize}", PrettySize(kvSettings.SegmentSize));

            logger?.LogInformation("[Store] Using hash index size of {IndexMemorySize} ({indexCacheLines} cache lines)", PrettySize(kvSettings.IndexSize), PrettySize(indexCacheLines));
            logger?.LogInformation("[Store] Hash index size is optimized for up to ~{distinctKeys} distinct keys", PrettySize(indexCacheLines * 4L));

            AdjustedIndexMaxCacheLines = IndexMaxMemorySize == string.Empty ? 0 : IndexSizeCachelines("hash index max size", IndexMaxMemorySize);

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Specify a main-log memory budget, e.g. --memory 256m (LogMemorySize).
  2. Or specify an explicit page count, e.g. --pagecount 512 (PageCount).
  3. When embedding, set kvSettings.LogMemorySize or kvSettings.PageCount before initializing the store.

Example fix

# before (fails: no memory or pagecount)
garnet-server

# after
garnet-server --memory 256m
# or
garnet-server --pagecount 512
Defensive patterns

Strategy: validation

Validate before calling

// Ensure the store has a memory budget OR an explicit page count
if (kvSettings.LogMemorySize <= 0 && kvSettings.PageCount == 0) {
    throw new InvalidOperationException("Specify LogMemorySize or PageCount for the store.");
}

Prevention

When it happens

Trigger: Starting the server with neither --memory (LogMemorySize) nor --pagecount (PageCount) specified for the store. Thrown at GarnetServerOptions.cs:711-712.

Common situations: A minimal/custom launcher that constructs GarnetServerOptions without setting MemorySize or PageCount; a config file that nulls out the default memory size; embedding Garnet via the API and forgetting to set KVSettings.LogMemorySize/PageCount.

Related errors


AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13). Data as JSON: /api/errors/3ad95a405e6a1f2c. Report an issue: GitHub.