{"record":{"id":"36c49b2259eb96d9","repo":"microsoft/garnet","slug":"maxinlinevaluesize-value-maxinlinevaluesize","errorCode":null,"errorMessage":"MaxInlineValueSize value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.","messagePattern":"MaxInlineValueSize value '(.+?)' \\((.+?) bytes\\) is outside the allowed range \\[(.+?), (.+?)\\] bytes\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/server/Servers/GarnetServerOptions.cs","lineNumber":927,"sourceCode":"        /// inline limit; see <c>LogSettings.MaxInlineValueSizeLimit</c> — this value MUST be kept in sync because LogSettings\n        /// is internal to Tsavorite.core and not visible from Garnet.server). If this value is not specified, it defaults\n        /// to the minimum of 1m or <paramref name=\"pageSize\"/> / 2; otherwise, the value must be &lt;= pageSize / 2.\n        /// <returns>The byte-length value used for <c>KVSettings.MaxInlineValueSize</c>.</returns>\n        /// <exception cref=\"Exception\">Thrown when the value cannot be parsed or is outside the allowed byte range.</exception>\n        /// </summary>\n        public int MaxInlineValueSizeBytes(long pageSize)\n        {\n            const long MinBytes = 0;                    // TODO: LogSettings.MinMaxInlineSize\n            const long MaxBytes = 0xFFFFFE;             // TODO: LogSettings.MaxInlineValueSizeLimit (= (1 << kValueLengthBits) - 2)\n\n            if (string.IsNullOrEmpty(MaxInlineValueSize))\n                return (int)Math.Min(pageSize / 2, KVSettings.DefaultMaxInlineValueSize);\n\n            if (!TryParseSize(MaxInlineValueSize, out var sizeInBytes))\n                throw new Exception($\"Unable to parse {nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}'. Expected a memory size string (e.g. '4k', '16m').\");\n\n            if (sizeInBytes < MinBytes || sizeInBytes > MaxBytes)\n                throw new Exception($\"{nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is outside the allowed range [{MinBytes}, {MaxBytes}] bytes.\");\n\n            // This check guarantees at least one record fits on a page, because the minimum page size is 4k, and 2k is larger than\n            // the PageHeader plus non-value components of a record (RecordInfo, RecordDataHeader, Key, and possible Optional fields).\n            if (sizeInBytes > pageSize / 2)\n                throw new Exception($\"{nameof(MaxInlineValueSize)} value '{MaxInlineValueSize}' ({sizeInBytes} bytes) is greater than half the page size ({pageSize / 2} bytes for PageSize {pageSize} bytes).\");\n\n            return (int)sizeInBytes;\n        }\n\n        /// <summary>\n        /// Parse <see cref=\"InitialIORecordSize\"/> as a byte count.\n        /// Returns <see cref=\"KVSettings.UseDefaultInitialIORecordSize\"/> if the value is null or empty (use default).\n        /// </summary>\n        /// <returns>The byte value used for <c>KVSettings.InitialIORecordSize</c>, or <see cref=\"KVSettings.UseDefaultInitialIORecordSize\"/> if unset.</returns>\n        /// <exception cref=\"Exception\">Thrown when the value cannot be parsed.</exception>\n        public int GetInitialIORecordSizeBytes()\n        {\n            if (string.IsNullOrEmpty(InitialIORecordSize))","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/server/Servers/GarnetServerOptions.cs#L909-L945","documentation":"After parsing, MaxInlineValueSize must be within [0, 0xFFFFFE] (16,777,214) bytes. The ceiling mirrors Tsavorite's RecordDataHeader value-length inline limit (LogSettings.MaxInlineValueSizeLimit = (1 << kValueLengthBits) - 2). Values above this cannot be represented in the inline record header.","triggerScenarios":"Setting --max-inline-value-size above ~16 MiB, e.g. '32m'. Thrown at GarnetServerOptions.cs:926-927.","commonSituations":"Over-tuning for very large values; assuming the inline limit tracks page or segment size rather than the fixed 24-bit header field.","solutions":["Keep --max-inline-value-size <= 16777214 bytes (e.g. '15m' is safe).","Remember an additional check caps it at pageSize/2 (see error 196), so in practice the effective max is half your page size.","Omit the flag to use the default min(pageSize/2, DefaultMaxInlineValueSize)."],"exampleFix":"# before (fails: 32m > ~16MiB)\ngarnet-server --max-inline-value-size 32m\n\n# after\ngarnet-server --max-inline-value-size 15m","handlingStrategy":"validation","validationCode":"const long MaxInlineValue = 0xFFFFFE;\nif (ServerOptions.TryParseSize(options.MaxInlineValueSize, out var v) && (v < 0 || v > MaxInlineValue)) {\n    throw new ArgumentOutOfRangeException($\"MaxInlineValueSize must be in [0, {MaxInlineValue}]\");\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Cap inline values at ~16 MiB (and in practice at pageSize/2).","Leave the default unless you have measured a need."],"tags":["garnet","config","tsavorite","storage","dotnet"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}