{"record":{"id":"f50beb3917abab4a","repo":"microsoft/garnet","slug":"need-to-set-commitfrequencyms-to-1-manual-commit","errorCode":null,"errorMessage":"Need to set CommitFrequencyMs to -1 (manual commits) with FastAofTruncate","messagePattern":"Need to set CommitFrequencyMs to -1 \\(manual commits\\) with FastAofTruncate","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"libs/host/GarnetServer.cs","lineNumber":485,"sourceCode":"            if (kvSettings.LogMemorySize > 0 || kvSettings.ReadCacheMemorySize > 0)\n            {\n                cacheSizeTracker.Initialize(store, kvSettings.LogMemorySize, kvSettings.ReadCacheMemorySize, this.loggerFactory);\n                sizeTracker = cacheSizeTracker;\n            }\n            return store;\n        }\n\n        private GarnetAppendOnlyFile CreateAOF(int dbId)\n        {\n            if (!opts.EnableAOF)\n            {\n                if (opts.CommitFrequencyMs != 0 || opts.WaitForCommit)\n                    throw new Exception(\"Cannot use CommitFrequencyMs or CommitWait without EnableAOF\");\n                return null;\n            }\n\n            if (opts.FastAofTruncate && opts.CommitFrequencyMs != -1)\n                throw new Exception(\"Need to set CommitFrequencyMs to -1 (manual commits) with FastAofTruncate\");\n\n            opts.GetAofSettings(dbId, out var aofSettings);\n            var appendOnlyFile = new GarnetAppendOnlyFile(opts, aofSettings, logger: this.loggerFactory?.CreateLogger(\"GarnetLog [aof]\"));\n\n            if (opts.CommitFrequencyMs < 0 && opts.WaitForCommit)\n                throw new Exception(\"Cannot use CommitWait with manual commits\");\n            return appendOnlyFile;\n        }\n\n        /// <summary>\n        /// Start server instance\n        /// </summary>\n        public void Start()\n        {\n#pragma warning disable VSTHRD002 // Server startup is synchronous and must complete recovery before accepting connections.\n            Provider.RecoverAsync().AsTask().GetAwaiter().GetResult();\n#pragma warning restore VSTHRD002\n            for (var i = 0; i < servers.Length; i++)","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/GarnetServer.cs#L467-L503","documentation":"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.","triggerScenarios":"Configuring GarnetServerOptions with FastAofTruncate=true and CommitFrequencyMs set to any value other than -1 (e.g., the default 0, or a positive millisecond interval).","commonSituations":"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.","solutions":["Set CommitFrequencyMs=-1 to enable manual commit mode when using FastAofTruncate.","Alternatively, disable FastAofTruncate if you want time-based automatic commits.","Ensure your application code handles manual commit calls if using CommitFrequencyMs=-1."],"exampleFix":"// before\nvar opts = new GarnetServerOptions\n{\n    EnableAOF = true,\n    FastAofTruncate = true,\n    CommitFrequencyMs = 1000  // must be -1\n};\n\n// after\nvar opts = new GarnetServerOptions\n{\n    EnableAOF = true,\n    FastAofTruncate = true,\n    CommitFrequencyMs = -1\n};","handlingStrategy":"validation","validationCode":"if (opts.FastAofTruncate && opts.EnableAOF && opts.CommitFrequencyMs != -1)\n    throw new InvalidOperationException(\n        \"FastAofTruncate requires CommitFrequencyMs=-1 (manual commits). \" +\n        \"Set CommitFrequencyMs=-1 or disable FastAofTruncate.\");","typeGuard":"static bool AreFastTruncateSettingsConsistent(GarnetServerOptions opts) =>\n    !opts.FastAofTruncate || !opts.EnableAOF || opts.CommitFrequencyMs == -1;","tryCatchPattern":null,"preventionTips":["Always pair FastAofTruncate=true with CommitFrequencyMs=-1.","Implement manual commit logic in your application when using manual commit mode.","Document the FastAofTruncate + manual commit dependency in config templates."],"tags":["aof","persistence","configuration","feature-conflict"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}