microsoft/garnet · error · Exception

Invalid {name}

Error message

Invalid {name}

What it means

Garnet validates that the index size (hash index) is between 64 bytes and 2^37 bytes (137 GB) after rounding to the nearest power of two. Values outside this range are rejected with a generic 'Invalid {name}' message. This applies to IndexSizeCachelines() which converts the size to cacheline (64-byte) units.

Source

Thrown at libs/server/Servers/ServerOptions.cs:208

        /// <returns></returns>
        public int SegmentSizeBits(bool isObj)
        {
            long size = ParseSize(isObj ? ObjectLogSegmentSize : SegmentSize, out _);
            long adjustedSize = PreviousPowerOf2(size);
            if (size != adjustedSize)
                logger?.LogInformation("Warning: using lower {SegmentType} than specified (power of 2)", isObj ? "ObjSegmentSize" : "SegmentSize");
            return (int)Math.Log(adjustedSize, 2);
        }

        /// <summary>
        /// Get index size
        /// </summary>
        /// <returns></returns>
        public int IndexSizeCachelines(string name, string indexSize)
        {
            long size = ParseSize(indexSize, out _);
            long adjustedSize = PreviousPowerOf2(size);
            if (adjustedSize < 64 || adjustedSize > (1L << 37)) throw new Exception($"Invalid {name}");
            if (size != adjustedSize)
                logger?.LogInformation("Warning: using lower {name} than specified (power of 2)", name);
            return (int)(adjustedSize / 64);
        }

        /// <summary>
        /// Parse size from string specification
        /// </summary>
        /// <param name="value"></param>
        /// <param name="bytesRead"></param>
        /// <returns></returns>
        public static long ParseSize(string value, out int bytesRead)
        {
            ReadOnlySpan<char> suffix = ['k', 'm', 'g', 't', 'p'];
            long result = 0;
            bytesRead = 0;
            for (var i = 0; i < value.Length; i++)
            {

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Set --index-size to a power-of-two value between 64 and 137438953472 (e.g., --index-size 16m for a typical deployment).
  2. Remove the index-size override to use Garnet's default.
  3. Double-check the value and unit suffix (k, m, g) if using size notation.

Example fix

// before
--index-size 32

// after
--index-size 64
Defensive patterns

Strategy: validation

Validate before calling

var size = ServerOptions.ParseSize(options.IndexSize, out _);
var rounded = PreviousPowerOf2(size);
if (rounded < 64 || rounded > (1L << 37))
    throw new InvalidOperationException($"Index size {options.IndexSize} is out of range [64, {1L << 37}].");

Prevention

When it happens

Trigger: Calling IndexSizeCachelines() with a value that rounds to less than 64 bytes or more than 2^37 bytes. For example, --index-size 32 or --index-size 200000000000 (200PB).

Common situations: Typo in index-size config (too many or too few zeros); misunderstanding units (entering 1 meaning 1 byte instead of 1MB); copy-paste from a config using different unit conventions.

Related errors


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