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
- Set --index-size to a power-of-two value between 64 and 137438953472 (e.g., --index-size 16m for a typical deployment).
- Remove the index-size override to use Garnet's default.
- 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
- Use a reasonable index size like 16m or 64m for typical deployments.
- Double-check exponent and unit suffix on index-size values.
- Validate index size in config before deployment.
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
- AofMemorySize (effective {effectiveMemory} after rounding do
- AofPageSize (effective {effectivePage} after rounding down t
- AofPageSize (effective {effectiveAofPage} after rounding dow
- Cannot use null device for AOF when cluster is enabled and y
- {propName} '{value}' (effective {adjustedSize} bytes after r
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/8cc97b25a0a4a834.
Report an issue: GitHub.