microsoft/garnet · error · Exception

RevivBinBestFitScanLimit must be >= 0.

Error message

RevivBinBestFitScanLimit must be >= 0.

What it means

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.

Source

Thrown at libs/host/Configuration/Options.cs:814

                    throw new Exception("Incompatible revivification record size and count cardinality.");
                if (RevivInChainOnly.GetValueOrDefault())
                    throw new Exception("Revivification cannot specify both record sizes and in-chain-only.");
                useRevivBinsPowerOf2 = false;
            }
            if (hasRecordCounts)
            {
                if (useRevivBinsPowerOf2)
                    throw new Exception("Revivification cannot specify both record counts and powerof2 bins.");
                if (!hasRecordSizes)
                    throw new Exception("Revivification bin counts require bin sizes.");
                useRevivBinsPowerOf2 = false;
            }
            if (RevivBinBestFitScanLimit != 0)
            {
                if (!hasRecordSizes && !enableRevivification)
                    throw new Exception("Revivification cannot specify best fit scan limit without specifying bins.");
                if (RevivBinBestFitScanLimit < 0)
                    throw new Exception("RevivBinBestFitScanLimit must be >= 0.");
            }
            if (RevivifiableFraction != RevivificationSettings.DefaultRevivifiableFraction)
            {
                if (!hasRecordSizes && !enableRevivification)
                    throw new Exception("Revivification cannot specify RevivifiableFraction without specifying bins.");
            }

            // Warn users who explicitly opt into Scan compaction about the memory-spike cost.
            // Scan builds a temporary parallel KV index proportional to the keyspace; Lookup is the recommended alternative.
            if (CompactionType == LogCompactionType.Scan)
            {
                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.");
            }

            if (SlowLogThreshold > 0)
            {
                if (SlowLogThreshold < 100)
                    throw new Exception("SlowLogThreshold must be at least 100 microseconds.");

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Set RevivBinBestFitScanLimit to 0 (disabled) or a positive integer.
  2. If you intended 'scan all bins', use a large positive number or the documented maximum.

Example fix

// before
options.RevivBinBestFitScanLimit = -1;

// after
options.RevivBinBestFitScanLimit = 0; // disabled
Defensive patterns

Strategy: validation

Validate before calling

void ValidateScanLimitRange(int scanLimit)
{
    if (scanLimit < 0)
        throw new ArgumentOutOfRangeException(nameof(scanLimit), "RevivBinBestFitScanLimit must be >= 0.");
}

Try / catch

try
{
    options.Initialize(logger);
}
catch (Exception ex) when (ex.Message.Contains("must be >= 0"))
{
    logger.LogError("RevivBinBestFitScanLimit cannot be negative. Use 0 to disable.");
    throw;
}

Prevention

When it happens

Trigger: 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.

Common situations: Using -1 as an 'unlimited' or 'disabled' sentinel (not supported here); config file corruption; off-by-one from a computation.

Related errors


AI-assisted analysis of microsoft/garnet@951b0fc683 (2026-08-13). Data as JSON: /api/errors/20ff1d82fcbb9d4d. Report an issue: GitHub.