{"record":{"id":"fb612fbf3c1b9a61","repo":"microsoft/garnet","slug":"slowlogthreshold-must-be-at-least-100-microseconds","errorCode":null,"errorMessage":"SlowLogThreshold must be at least 100 microseconds.","messagePattern":"SlowLogThreshold must be at least 100 microseconds\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/host/Configuration/Options.cs","lineNumber":832,"sourceCode":"                    throw new Exception(\"RevivBinBestFitScanLimit must be >= 0.\");\n            }\n            if (RevivifiableFraction != RevivificationSettings.DefaultRevivifiableFraction)\n            {\n                if (!hasRecordSizes && !enableRevivification)\n                    throw new Exception(\"Revivification cannot specify RevivifiableFraction without specifying bins.\");\n            }\n\n            // Warn users who explicitly opt into Scan compaction about the memory-spike cost.\n            // Scan builds a temporary parallel KV index proportional to the keyspace; Lookup is the recommended alternative.\n            if (CompactionType == LogCompactionType.Scan)\n            {\n                logger?.LogWarning(\"Compaction type Scan builds a temporary parallel KV index proportional to the keyspace, causing significant transient memory use. Use Lookup instead unless you have a specific reason for Scan.\");\n            }\n\n            if (SlowLogThreshold > 0)\n            {\n                if (SlowLogThreshold < 100)\n                    throw new Exception(\"SlowLogThreshold must be at least 100 microseconds.\");\n            }\n\n\n            if (!EnableAOF.GetValueOrDefault())\n            {\n                if (!string.IsNullOrEmpty(AofSizeLimit))\n                    throw new GarnetException(\"AofSizeLimit cannot be enforced with disabled AOF!\");\n            }\n\n            Func<INamedDeviceFactoryCreator> azureFactoryCreator = () =>\n            {\n                if (!string.IsNullOrEmpty(AzureStorageConnectionString))\n                {\n                    return new AzureStorageNamedDeviceFactoryCreator(AzureStorageConnectionString, logger);\n                }\n                var credential = new ChainedTokenCredential(\n                    new WorkloadIdentityCredential(),\n                    new ManagedIdentityCredential(clientId: AzureStorageManagedIdentity)","sourceCodeStart":814,"sourceCodeEnd":850,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/Configuration/Options.cs#L814-L850","documentation":"Generic Exception thrown during Options.Initialize when SlowLogThreshold is set to a positive value less than 100 (microseconds). The slow log threshold must be either 0 (disabled) or at least 100 microseconds. Values between 1 and 99 are rejected because they would log nearly every command and are considered misconfiguration.","triggerScenarios":"Setting --slowlog-threshold (SlowLogThreshold) to any value in the range 1–99 inclusive. Common when a user confuses microseconds with milliseconds and enters a small number expecting millisecond granularity.","commonSituations":"User sets SlowLogThreshold=50 thinking it means 50 ms (actually 50 µs); copying a threshold value from a system that uses different units; attempting to log everything by setting a very low threshold.","solutions":["Set SlowLogThreshold to 0 to disable the slow log, or to 100 or higher (in microseconds).","Remember the unit is microseconds: 100 µs = 0.1 ms; for a 5 ms threshold use 5000."],"exampleFix":"// before: user meant 50 ms but wrote 50 (microseconds)\noptions.SlowLogThreshold = 50;\n\n// after: 50 ms in microseconds\noptions.SlowLogThreshold = 50000;","handlingStrategy":"validation","validationCode":"void ValidateSlowLogThreshold(long threshold)\n{\n    // threshold is in microseconds; 0 disables, otherwise must be >= 100\n    if (threshold != 0 && threshold < 100)\n        throw new ArgumentOutOfRangeException(nameof(threshold), \"SlowLogThreshold must be 0 (disabled) or >= 100 microseconds.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    options.Initialize(logger);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"SlowLogThreshold\"))\n{\n    logger.LogError(\"SlowLogThreshold must be 0 or >= 100 microseconds. Did you mean milliseconds? 50 ms = 50000.\");\n    throw;\n}","preventionTips":["Remember the unit is microseconds, not milliseconds — multiply ms values by 1000.","Validate the threshold range in your config loader before passing to Options."],"tags":["config","slowlog","validation","range","units","options"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}