microsoft/garnet · error · Exception

MaxInlineKeySize value '{MaxInlineKeySize}' ({sizeInBytes} b

Error message

MaxInlineKeySize value '{MaxInlineKeySize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.

What it means

After parsing, MaxInlineKeySize must fall within [0, 1022] bytes. The 1022-byte upper bound mirrors Tsavorite's LogSettings.MaxInlineKeySizeLimit ((1 << kKeyLengthBits) - 2), which is the largest key that can be stored inline in the in-memory record header. Values above 1022 cannot be inlined and must go through the object log.

Source

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

        /// <summary>
        /// Parse <see cref="MaxInlineKeySize"/> as a byte count.
        /// Returns the default value (1022 bytes, the Tsavorite limit) if the value is null or empty.
        /// </summary>
        /// <returns>The byte-length value used for <c>KVSettings.MaxInlineKeySize</c>.</returns>
        /// <exception cref="Exception">Thrown when the value cannot be parsed or is outside the allowed range.</exception>
        public int MaxInlineKeySizeBytes()
        {
            const long MinBytes = 0;                    // TODO: LogSettings.MinMaxInlineSize
            const long MaxBytes = 1022;                 // TODO: LogSettings.MaxInlineKeySizeLimit (= (1 << kKeyLengthBits) - 2)

            if (string.IsNullOrEmpty(MaxInlineKeySize))
                return KVSettings.DefaultMaxInlineKeySize;

            if (!TryParseSize(MaxInlineKeySize, out var sizeInBytes))
                throw new Exception($"Unable to parse {nameof(MaxInlineKeySize)} value '{MaxInlineKeySize}'. Expected a memory size string (e.g. '1k', '128').");

            if (sizeInBytes < MinBytes || sizeInBytes > MaxBytes)
                throw new Exception($"{nameof(MaxInlineKeySize)} value '{MaxInlineKeySize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.");

            return (int)sizeInBytes;
        }

        /// <summary>
        /// Parse and validate <see cref="MaxInlineValueSize"/> as a byte count.
        /// Tsavorite requires this to be at most 0xFFFFFE (the RecordDataHeader value-length field's
        /// inline limit; see <c>LogSettings.MaxInlineValueSizeLimit</c> — this value MUST be kept in sync because LogSettings
        /// is internal to Tsavorite.core and not visible from Garnet.server). If this value is not specified, it defaults
        /// to the minimum of 1m or <paramref name="pageSize"/> / 2; otherwise, the value must be &lt;= pageSize / 2.
        /// <returns>The byte-length value used for <c>KVSettings.MaxInlineValueSize</c>.</returns>
        /// <exception cref="Exception">Thrown when the value cannot be parsed or is outside the allowed byte range.</exception>
        /// </summary>
        public int MaxInlineValueSizeBytes(long pageSize)
        {
            const long MinBytes = 0;                    // TODO: LogSettings.MinMaxInlineSize
            const long MaxBytes = 0xFFFFFE;             // TODO: LogSettings.MaxInlineValueSizeLimit (= (1 << kValueLengthBits) - 2)

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Keep --max-inline-key-size <= 1022 bytes (the default is already 1022).
  2. Leave the flag unset to use the default, which is the maximum allowed.
  3. If you have larger keys, accept that they will be stored via the object log rather than raising this limit.

Example fix

# before (fails: 2k > 1022)
garnet-server --max-inline-key-size 2k

# after
garnet-server --max-inline-key-size 1022   # or omit the flag
Defensive patterns

Strategy: validation

Validate before calling

const long MaxInlineKey = 1022;
if (ServerOptions.TryParseSize(options.MaxInlineKeySize, out var k) && (k < 0 || k > MaxInlineKey)) {
    throw new ArgumentOutOfRangeException($"MaxInlineKeySize must be in [0, {MaxInlineKey}]");
}

Prevention

When it happens

Trigger: Setting --max-inline-key-size to a value > 1022 (e.g. '2k' = 2048) or a negative value. Thrown at GarnetServerOptions.cs:900-901.

Common situations: Assuming keys can be arbitrarily large inline; copying a config expecting kilobyte-scale inline keys; misunderstanding that large keys spill to the object log regardless.

Related errors


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