{"record":{"id":"66adc9013e14b82b","repo":"microsoft/garnet","slug":"nameof-logsettings-maxinlinevaluesize-must-be-b","errorCode":null,"errorMessage":"{nameof(logSettings.MaxInlineValueSize)} must be between {LogSettings.MinMaxInlineSize} and {LogSettings.MaxInlineValueSizeLimit}","messagePattern":"(.+?) must be between (.+?) and (.+?)","errorType":"validation","errorClass":"TsavoriteException","httpStatus":null,"severity":"error","filePath":"libs/storage/Tsavorite/cs/src/core/Allocator/AllocatorBase.cs","lineNumber":583,"sourceCode":"                var rcs = logSettings.ReadCacheSettings;\n                if (rcs.PageCount == 0 && rcs.MemorySize == 0)\n                    throw new TsavoriteException($\"{nameof(rcs.PageCount)} or {nameof(rcs.MemorySize)} must be specified\");\n                if (rcs.PageSizeBits < LogSettings.kMinPageSizeBits || rcs.PageSizeBits > LogSettings.kMaxPageSizeBits)\n                    throw new TsavoriteException($\"{nameof(rcs.PageSizeBits)} must be between {LogSettings.kMinPageSizeBits} and {LogSettings.kMaxPageSizeBits}\");\n                if (rcs.PageCount > MemoryUtils.ArrayMaxLength)\n                    throw new TsavoriteException($\"{nameof(rcs.PageCount)} must be less than or equal to the maximum array length ({MemoryUtils.ArrayMaxLength})\");\n                if (rcs.MemorySize != 0 && (rcs.MemorySize < 1L << LogSettings.kMinMemorySizeBits || rcs.MemorySize > 1L << LogSettings.kMaxMemorySizeBits))\n                    throw new TsavoriteException($\"{nameof(rcs.MemorySize)} must be between {1L << LogSettings.kMinMemorySizeBits} and {1L << LogSettings.kMaxMemorySizeBits}\");\n                if ((rcs.MemorySize != 0) && (rcs.MemorySize < (1L << rcs.PageSizeBits) * 2))\n                    throw new TsavoriteException($\"{nameof(logSettings.MemorySize)} must be at least twice the page size ({1L << rcs.PageSizeBits})\");\n                if (rcs.SecondChanceFraction < 0.0 || rcs.SecondChanceFraction > 1.0)\n                    throw new TsavoriteException($\"{rcs.SecondChanceFraction} must be >= 0.0 and <= 1.0\");\n            }\n\n            if (logSettings.MaxInlineKeySize < LogSettings.MinMaxInlineSize || logSettings.MaxInlineKeySize > LogSettings.MaxInlineKeySizeLimit)\n                throw new TsavoriteException($\"{nameof(logSettings.MaxInlineKeySize)} must be between {LogSettings.MinMaxInlineSize} and {LogSettings.MaxInlineKeySizeLimit}\");\n            if (logSettings.MaxInlineValueSize < LogSettings.MinMaxInlineSize || logSettings.MaxInlineValueSize > LogSettings.MaxInlineValueSizeLimit)\n                throw new TsavoriteException($\"{nameof(logSettings.MaxInlineValueSize)} must be between {LogSettings.MinMaxInlineSize} and {LogSettings.MaxInlineValueSizeLimit}\");\n\n            this.logger = logger;\n            if (logSettings.LogDevice == null)\n                throw new TsavoriteException(\"LogSettings.LogDevice needs to be specified (e.g., use Devices.CreateLogDevice, AzureStorageDevice, or NullDevice)\");\n\n            EvictCallback = evictCallback;\n\n            FlushCallback = flushCallback;\n            PreallocateLog = logSettings.PreallocateLog;\n            flushEvent.Initialize();\n\n            IsNullDevice = logSettings.LogDevice is NullDevice;\n\n            if (epoch == null)\n            {\n                this.epoch = new LightEpoch();\n                isEpochOwned = true;\n            }","sourceCodeStart":565,"sourceCodeEnd":601,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/storage/Tsavorite/cs/src/core/Allocator/AllocatorBase.cs#L565-L601","documentation":"Constructor validation: logSettings.MaxInlineValueSize must be in [MinMaxInlineSize, MaxInlineValueSizeLimit] = [0, (1<<RecordDataHeader.kValueLengthBits)-2] = [0, 16,777,214]. Values up to this many bytes are stored inline in the SpanByteAllocator in-memory record; larger values overflow. The upper limit is dictated by the 24-bit ValueLength field of RecordDataHeader. Default is 4096.","triggerScenarios":"Setting MaxInlineValueSize above 16,777,214 (~16MiB) or below 0.","commonSituations":"Raising inline value size to avoid overflow for large blobs and overshooting the 24-bit field; negative from a config sentinel.","solutions":["Keep MaxInlineValueSize within [0, 16,777,214]; default 4096 is typical.","For larger values, let them overflow rather than raising the inline ceiling.","0 is valid for a pure object store."],"exampleFix":"// before\nlogSettings.MaxInlineValueSize = 1 << 25;  // 33MiB -> exceeds 24-bit field\n// after\nlogSettings.MaxInlineValueSize = (1 << 24) - 2; // 16,777,214 max","handlingStrategy":"validation","validationCode":"const int MaxInlineValue = (1 << 24) - 2; // MaxInlineValueSizeLimit = 16,777,214 (24-bit ValueLength field)\nif (logSettings.MaxInlineValueSize < 0 || logSettings.MaxInlineValueSize > MaxInlineValue)\n    logSettings.MaxInlineValueSize = Math.Clamp(logSettings.MaxInlineValueSize, 0, MaxInlineValue);","typeGuard":null,"tryCatchPattern":"try { new TsavoriteKV<K,V>(logSettings, ...); }\ncatch (TsavoriteException ex) when (ex.Message.Contains(\"MaxInlineValueSize\"))\n{ /* clamp to [0,16,777,214]; let larger values overflow */ }","preventionTips":["Do not raise MaxInlineValueSize above 16,777,214; let large values overflow.","Keep the default 4096 unless measurement shows benefit.","Clamp value-size config in your settings loader."],"tags":["storage","configuration","log-settings","inline-size","value"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}