microsoft/garnet · critical · Exception
Cannot use CommitWait with manual commits
Error message
Cannot use CommitWait with manual commits
What it means
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.
Source
Thrown at libs/host/GarnetServer.cs:491
}
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++)
servers[i].Start();
Provider.Start();
if (!opts.QuietMode)
Console.WriteLine("* Ready to accept connections");
}
View on GitHub (pinned to 951b0fc683)
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.
Example fix
// before
var opts = new GarnetServerOptions
{
EnableAOF = true,
CommitFrequencyMs = -1, // manual
WaitForCommit = true // cannot wait in manual mode
};
// after: use automatic commits with wait
var opts = new GarnetServerOptions
{
EnableAOF = true,
CommitFrequencyMs = 1000,
WaitForCommit = true
}; Defensive patterns
Strategy: validation
Validate before calling
if (opts.EnableAOF && opts.CommitFrequencyMs < 0 && opts.WaitForCommit)
throw new InvalidOperationException(
"WaitForCommit cannot be used with manual commits (CommitFrequencyMs < 0). " +
"Use a positive CommitFrequencyMs for automatic commits with wait."); Type guard
static bool AreCommitWaitSettingsConsistent(GarnetServerOptions opts) =>
!opts.EnableAOF || opts.CommitFrequencyMs >= 0 || !opts.WaitForCommit; Prevention
- 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.
When it happens
Trigger: Configuring GarnetServerOptions with EnableAOF=true, CommitFrequencyMs < 0 (manual commits), and WaitForCommit=true simultaneously. The check is at GarnetServer.cs:490.
Common situations: 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.
Related errors
- Cannot use CommitFrequencyMs or CommitWait without EnableAOF
- Need to set CommitFrequencyMs to -1 (manual commits) with Fa
- AofSizeLimit cannot be enforced with disabled AOF!
- AofMemorySize (effective {effectiveMemory} after rounding do
- AofPageSize (effective {effectivePage} after rounding down t
AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13).
Data as JSON: /api/errors/4cc53495cd21e112.
Report an issue: GitHub.