microsoft/garnet · critical · Exception

Need to set CommitFrequencyMs to -1 (manual commits) with Fa

Error message

Need to set CommitFrequencyMs to -1 (manual commits) with FastAofTruncate

What it means

Thrown by GarnetServer.CreateAOF when FastAofTruncate is enabled but CommitFrequencyMs is not set to -1. Fast AOF truncation requires manual commit mode (CommitFrequencyMs=-1) because it manages the AOF tail differently — automatic time-based commits would conflict with the truncation logic. The check is at GarnetServer.cs:484.

Source

Thrown at libs/host/GarnetServer.cs:485

            if (kvSettings.LogMemorySize > 0 || kvSettings.ReadCacheMemorySize > 0)
            {
                cacheSizeTracker.Initialize(store, kvSettings.LogMemorySize, kvSettings.ReadCacheMemorySize, this.loggerFactory);
                sizeTracker = cacheSizeTracker;
            }
            return store;
        }

        private GarnetAppendOnlyFile CreateAOF(int dbId)
        {
            if (!opts.EnableAOF)
            {
                if (opts.CommitFrequencyMs != 0 || opts.WaitForCommit)
                    throw new Exception("Cannot use CommitFrequencyMs or CommitWait without EnableAOF");
                return null;
            }

            if (opts.FastAofTruncate && opts.CommitFrequencyMs != -1)
                throw new Exception("Need to set CommitFrequencyMs to -1 (manual commits) with FastAofTruncate");

            opts.GetAofSettings(dbId, out var aofSettings);
            var appendOnlyFile = new GarnetAppendOnlyFile(opts, aofSettings, logger: this.loggerFactory?.CreateLogger("GarnetLog [aof]"));

            if (opts.CommitFrequencyMs < 0 && opts.WaitForCommit)
                throw new Exception("Cannot use CommitWait with manual commits");
            return appendOnlyFile;
        }

        /// <summary>
        /// Start server instance
        /// </summary>
        public void Start()
        {
#pragma warning disable VSTHRD002 // Server startup is synchronous and must complete recovery before accepting connections.
            Provider.RecoverAsync().AsTask().GetAwaiter().GetResult();
#pragma warning restore VSTHRD002
            for (var i = 0; i < servers.Length; i++)

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Set CommitFrequencyMs=-1 to enable manual commit mode when using FastAofTruncate.
  2. Alternatively, disable FastAofTruncate if you want time-based automatic commits.
  3. Ensure your application code handles manual commit calls if using CommitFrequencyMs=-1.

Example fix

// before
var opts = new GarnetServerOptions
{
    EnableAOF = true,
    FastAofTruncate = true,
    CommitFrequencyMs = 1000  // must be -1
};

// after
var opts = new GarnetServerOptions
{
    EnableAOF = true,
    FastAofTruncate = true,
    CommitFrequencyMs = -1
};
Defensive patterns

Strategy: validation

Validate before calling

if (opts.FastAofTruncate && opts.EnableAOF && opts.CommitFrequencyMs != -1)
    throw new InvalidOperationException(
        "FastAofTruncate requires CommitFrequencyMs=-1 (manual commits). " +
        "Set CommitFrequencyMs=-1 or disable FastAofTruncate.");

Type guard

static bool AreFastTruncateSettingsConsistent(GarnetServerOptions opts) =>
    !opts.FastAofTruncate || !opts.EnableAOF || opts.CommitFrequencyMs == -1;

Prevention

When it happens

Trigger: Configuring GarnetServerOptions with FastAofTruncate=true and CommitFrequencyMs set to any value other than -1 (e.g., the default 0, or a positive millisecond interval).

Common situations: Enabling FastAofTruncate for performance without understanding it requires manual commit mode; copying config from documentation that showed FastAofTruncate without the corresponding CommitFrequencyMs=-1; automated config tools that set FastAofTruncate independently.

Related errors


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