microsoft/garnet · critical · Exception

AofPageSize (effective {effectiveAofPage} after rounding dow

Error message

AofPageSize (effective {effectiveAofPage} after rounding down to a power of two) must be at least twice the main-log PageSize (effective {effectiveMainPage}). Increase --aof-page-size to at least {minAofPage} (and --aof-memory to at least {PrettySize(1L << (mainPageSizeBits + 2))}), or reduce --page.

What it means

Garnet requires the AOF page size to be at least twice the main log's page size. An AOF entry mirrors a main-log write (key + value + overhead), and raw-string SETs can fill an entire main-log page. If the AOF page is too small, the entry will not fit on a page at runtime, stalling the session. The check is pageSizeBits < mainPageSizeBits + 1.

Source

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

            // AofPageSize must be at least twice the main-log PageSize. An AOF entry mirrors a single
            // main-log write (key + value/input + small overhead); raw-string SETs can be as large as
            // the main-log PageSize (values above MaxInlineValueSize overflow to the heap on the main
            // store but are still written in full to the AOF), and object commands like LPUSH/HSET can
            // push the AOF entry even higher. Throw a clear error here so users do not hit the runtime
            // "Entry does not fit on page" path with a stalled session.
            var mainPageSizeBits = PageSizeBits();
            if (pageSizeBits < mainPageSizeBits + 1)
            {
                var effectiveAofPage = PrettySize(1L << pageSizeBits);
                var effectiveMainPage = PrettySize(1L << mainPageSizeBits);
                var minAofPage = PrettySize(1L << (mainPageSizeBits + 1));
                var msg = $"AofPageSize (effective {effectiveAofPage} after rounding down to a power of two) " +
                          $"must be at least twice the main-log PageSize (effective {effectiveMainPage}). " +
                          $"Increase --aof-page-size to at least {minAofPage} (and --aof-memory to at least {PrettySize(1L << (mainPageSizeBits + 2))}), " +
                          $"or reduce --page.";
                logger?.LogError("{msg}", msg);
                throw new Exception(msg);
            }

            tsavoriteLogSettings = new TsavoriteLogSettings[AofPhysicalSublogCount];
            for (var i = 0; i < AofPhysicalSublogCount; i++)
            {
                tsavoriteLogSettings[i] = new TsavoriteLogSettings
                {
                    MemorySizeBits = memorySizeBits,
                    PageSizeBits = pageSizeBits,
                    SegmentSizeBits = segmentSizeBits,
                    LogDevice = GetAofDevice(dbId, subLogIdx: AofPhysicalSublogCount == 1 ? -1 : i),
                    TryRecoverLatest = false,
                    FastCommitMode = true,
                    AutoCommit = AofAutoCommit && (AofPhysicalSublogCount == 1),
                    MutableFraction = 0.9,
                    Epoch = null
                };

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Increase --aof-page-size to at least twice the effective --page value, and ensure --aof-memory is at least 4× --page.
  2. Reduce --page so the existing --aof-page-size satisfies the 2× constraint.
  3. Remove --aof-page-size and --aof-memory overrides so Garnet computes compatible values from --page.

Example fix

// before
--page 32m --aof-page-size 32m

// after
--page 32m --aof-page-size 64m --aof-memory 128m
Defensive patterns

Strategy: validation

Validate before calling

var mainPageBits = options.PageSizeBits();
var aofPageBits = options.AofPageSizeBits();
if (aofPageBits < mainPageBits + 1)
    throw new InvalidOperationException($"AOF page ({1L << aofPageBits} bytes) must be >= 2x main page ({1L << mainPageBits} bytes).");

Try / catch

try { options.GetAofSettings(dbId, out var settings); }
catch (Exception ex) when (ex.Message.Contains("main-log PageSize"))
{ logger.LogError("AOF page must be 2x main page: {Msg}", ex.Message); throw; }

Prevention

When it happens

Trigger: Calling GetAofSettings() when AofPageSizeBits() < PageSizeBits() + 1. Occurs when --aof-page-size is less than 2× --page. For example, --page 32m --aof-page-size 32m fails because AOF page must be at least 64m.

Common situations: Increasing the main log --page for throughput without raising --aof-page-size; disabling AOF page override to use a default that is smaller than a custom main page; upgrading from a version without this cross-constraint check.

Related errors


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