microsoft/garnet · error · TsavoriteException

{nameof(settings.LogSettings.ObjectLogSegmentSizeBits)} must

Error message

{nameof(settings.LogSettings.ObjectLogSegmentSizeBits)} must be between {LogSettings.kMinObjectLogSegmentSizeBits} and {LogSettings.kMaxSegmentSizeBits}

What it means

Thrown by ObjectAllocatorImpl when LogSettings.ObjectLogSegmentSizeBits is less than kMinObjectLogSegmentSizeBits (22, i.e. 4MB) or greater than kMaxSegmentSizeBits (62). The object-log segment size also sizes the read/write buffers for object serialization, so it must be large enough to buffer a segment and bounded by the 62-bit address space.

Source

Thrown at libs/storage/Tsavorite/cs/src/core/Allocator/ObjectAllocatorImpl.cs:97

            maxInlineKeySize = settings.LogSettings.MaxInlineKeySize;
            maxInlineValueSize = settings.LogSettings.MaxInlineValueSize;

            ObjectLogSegmentSize = 1L << settings.LogSettings.ObjectLogSegmentSizeBits;

            freePagePool = new OverflowPool<PageUnit<ObjectPage>>(4, static p => { });
            pageHeaderSize = PageHeader.Size;

            if (settings.LogSettings.NumberOfFlushBuffers < LogSettings.kMinFlushBuffers || settings.LogSettings.NumberOfFlushBuffers > LogSettings.kMaxFlushBuffers || !IsPowerOfTwo(settings.LogSettings.NumberOfFlushBuffers))
                throw new TsavoriteException($"{nameof(settings.LogSettings.NumberOfFlushBuffers)} must be between {LogSettings.kMinFlushBuffers} and {LogSettings.kMaxFlushBuffers - 1} and a power of 2");
            numberOfFlushBuffers = settings.LogSettings.NumberOfFlushBuffers;

            if (settings.LogSettings.NumberOfDeserializationBuffers < LogSettings.kMinDeserializationBuffers || settings.LogSettings.NumberOfDeserializationBuffers > LogSettings.kMaxDeserializationBuffers || !IsPowerOfTwo(settings.LogSettings.NumberOfDeserializationBuffers))
                throw new TsavoriteException($"{nameof(settings.LogSettings.NumberOfDeserializationBuffers)} must be between {LogSettings.kMinDeserializationBuffers} and {LogSettings.kMaxDeserializationBuffers - 1} and a power of 2");
            numberOfDeserializationBuffers = settings.LogSettings.NumberOfDeserializationBuffers;

            if (settings.LogSettings.ObjectLogSegmentSizeBits is < LogSettings.kMinObjectLogSegmentSizeBits or > LogSettings.kMaxSegmentSizeBits)
                throw new TsavoriteException($"{nameof(settings.LogSettings.ObjectLogSegmentSizeBits)} must be between {LogSettings.kMinObjectLogSegmentSizeBits} and {LogSettings.kMaxSegmentSizeBits}");
            objectLogTail = new(0, settings.LogSettings.ObjectLogSegmentSizeBits);

            objectPages = new ObjectPage[BufferSize];
            for (var ii = 0; ii < BufferSize; ii++)
                objectPages[ii] = new();
        }

        /// <summary>Initialize allocator</summary>
        [MethodImpl(MethodImplOptions.NoInlining)]
        protected internal override void Initialize()
        {
            base.Initialize();
            LastIssuedFlushedUntilAddress = FlushedUntilAddress;
            OngoingFlushedUntilAddress = 0;
            NoFlushUntilAddress = 0;
        }

        internal int OverflowPageCount => freePagePool.Count;

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Keep ObjectLogSegmentSizeBits within [22, 62] (default 33).
  2. Do not set it below 22 even if page size is smaller; the object log needs its own minimum segment/buffer size.
  3. If lowering memory, reduce PageSizeBits/MemorySize instead of ObjectLogSegmentSizeBits.

Example fix

// before
logSettings.ObjectLogSegmentSizeBits = 20; // < kMinObjectLogSegmentSizeBits (22)
// after
logSettings.ObjectLogSegmentSizeBits = 22; // 4MB minimum
Defensive patterns

Strategy: validation

Validate before calling

if (logSettings.ObjectLogSegmentSizeBits is < LogSettings.kMinObjectLogSegmentSizeBits or > LogSettings.kMaxSegmentSizeBits)
    throw new ArgumentException($"ObjectLogSegmentSizeBits must be in [22,62]");

Prevention

When it happens

Trigger: Setting LogSettings.ObjectLogSegmentSizeBits outside [22, 62], e.g. matching it to a small PageSizeBits or an arbitrary value, when constructing an object store. Default is 33 (8GB).

Common situations: Reducing ObjectLogSegmentSizeBits to cut buffer memory without knowing the 4MB floor; setting it equal to PageSizeBits for uniformity (PageSizeBits is often 25 < 22? no, but e.g. 20 would fail); bumping it very high to avoid segment crossings and exceeding 62.

Related errors


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