{"record":{"id":"20ff1d82fcbb9d4d","repo":"microsoft/garnet","slug":"revivbinbestfitscanlimit-must-be-0","errorCode":null,"errorMessage":"RevivBinBestFitScanLimit must be >= 0.","messagePattern":"RevivBinBestFitScanLimit must be >= 0\\.","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/host/Configuration/Options.cs","lineNumber":814,"sourceCode":"                    throw new Exception(\"Incompatible revivification record size and count cardinality.\");\n                if (RevivInChainOnly.GetValueOrDefault())\n                    throw new Exception(\"Revivification cannot specify both record sizes and in-chain-only.\");\n                useRevivBinsPowerOf2 = false;\n            }\n            if (hasRecordCounts)\n            {\n                if (useRevivBinsPowerOf2)\n                    throw new Exception(\"Revivification cannot specify both record counts and powerof2 bins.\");\n                if (!hasRecordSizes)\n                    throw new Exception(\"Revivification bin counts require bin sizes.\");\n                useRevivBinsPowerOf2 = false;\n            }\n            if (RevivBinBestFitScanLimit != 0)\n            {\n                if (!hasRecordSizes && !enableRevivification)\n                    throw new Exception(\"Revivification cannot specify best fit scan limit without specifying bins.\");\n                if (RevivBinBestFitScanLimit < 0)\n                    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.\");","sourceCodeStart":796,"sourceCodeEnd":832,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/Configuration/Options.cs#L796-L832","documentation":"Generic Exception thrown during Options.Initialize revivification validation when RevivBinBestFitScanLimit is a negative number. The scan limit represents a count of bins to scan, which cannot be negative. This is a straightforward range guard on an integer config field.","triggerScenarios":"Setting RevivBinBestFitScanLimit to any value less than 0. Typically a typo, a sign error, or a config generator emitting -1 as a sentinel that this code does not accept.","commonSituations":"Using -1 as an 'unlimited' or 'disabled' sentinel (not supported here); config file corruption; off-by-one from a computation.","solutions":["Set RevivBinBestFitScanLimit to 0 (disabled) or a positive integer.","If you intended 'scan all bins', use a large positive number or the documented maximum."],"exampleFix":"// before\noptions.RevivBinBestFitScanLimit = -1;\n\n// after\noptions.RevivBinBestFitScanLimit = 0; // disabled","handlingStrategy":"validation","validationCode":"void ValidateScanLimitRange(int scanLimit)\n{\n    if (scanLimit < 0)\n        throw new ArgumentOutOfRangeException(nameof(scanLimit), \"RevivBinBestFitScanLimit must be >= 0.\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    options.Initialize(logger);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"must be >= 0\"))\n{\n    logger.LogError(\"RevivBinBestFitScanLimit cannot be negative. Use 0 to disable.\");\n    throw;\n}","preventionTips":["Do not use -1 as a sentinel; this API uses 0 for 'disabled'.","Range-check integer config fields at load time."],"tags":["config","revivification","validation","range","options"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}