{"record":{"id":"4cc53495cd21e112","repo":"microsoft/garnet","slug":"cannot-use-commitwait-with-manual-commits","errorCode":null,"errorMessage":"Cannot use CommitWait with manual commits","messagePattern":"Cannot use CommitWait with manual commits","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"critical","filePath":"libs/host/GarnetServer.cs","lineNumber":491,"sourceCode":"        }\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++)\n                servers[i].Start();\n            Provider.Start();\n            if (!opts.QuietMode)\n                Console.WriteLine(\"* Ready to accept connections\");\n        }\n","sourceCodeStart":473,"sourceCodeEnd":509,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/GarnetServer.cs#L473-L509","documentation":"Thrown by GarnetServer.CreateAOF when WaitForCommit (CommitWait) is enabled but CommitFrequencyMs is negative, indicating manual commit mode. CommitWait means the server should block and wait for each commit to flush; in manual mode, commits are triggered by the application, so waiting for an automatic commit would hang indefinitely. These two settings are logically incompatible.","triggerScenarios":"Configuring GarnetServerOptions with EnableAOF=true, CommitFrequencyMs < 0 (manual commits), and WaitForCommit=true simultaneously. The check is at GarnetServer.cs:490.","commonSituations":"Combining manual commit mode with synchronous wait semantics by mistake; config templates that set CommitWait=true globally; enabling CommitWait without realizing CommitFrequencyMs was set to -1 for FastAofTruncate.","solutions":["If using manual commits (CommitFrequencyMs=-1), set WaitForCommit=false and manage commits in application code.","If you need CommitWait, set CommitFrequencyMs to a positive value for automatic timed commits.","Review the interaction between FastAofTruncate (requires -1), CommitFrequencyMs, and WaitForCommit."],"exampleFix":"// before\nvar opts = new GarnetServerOptions\n{\n    EnableAOF = true,\n    CommitFrequencyMs = -1,  // manual\n    WaitForCommit = true     // cannot wait in manual mode\n};\n\n// after: use automatic commits with wait\nvar opts = new GarnetServerOptions\n{\n    EnableAOF = true,\n    CommitFrequencyMs = 1000,\n    WaitForCommit = true\n};","handlingStrategy":"validation","validationCode":"if (opts.EnableAOF && opts.CommitFrequencyMs < 0 && opts.WaitForCommit)\n    throw new InvalidOperationException(\n        \"WaitForCommit cannot be used with manual commits (CommitFrequencyMs < 0). \" +\n        \"Use a positive CommitFrequencyMs for automatic commits with wait.\");","typeGuard":"static bool AreCommitWaitSettingsConsistent(GarnetServerOptions opts) =>\n    !opts.EnableAOF || opts.CommitFrequencyMs >= 0 || !opts.WaitForCommit;","tryCatchPattern":null,"preventionTips":["Never combine WaitForCommit=true with CommitFrequencyMs < 0.","Understand the three-way interaction: FastAofTruncate forces -1, which conflicts with WaitForCommit.","Validate AOF settings as a coherent group before server start."],"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"}