microsoft/garnet · error · Exception

Revivification cannot specify both record counts and powerof

Error message

Revivification cannot specify both record counts and powerof2 bins.

What it means

Generic Exception thrown during Options.Initialize revivification validation when RevivBinRecordCounts is specified AND power-of-2 bins are still enabled (useRevivBinsPowerOf2 defaults to true when EnableRevivification is true). Power-of-2 bins auto-generate bin sizes/count internally, so specifying explicit counts conflicts with that auto-generation. The two are mutually exclusive.

Source

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

            var unixSocketPermissions = (UnixFileMode)Convert.ToInt32(UnixSocketPermission.ToString(), 8);

            var revivBinRecordSizes = this.RevivBinRecordSizes?.ToArray();
            var revivBinRecordCounts = this.RevivBinRecordCounts?.ToArray();
            bool hasRecordSizes = revivBinRecordSizes?.Length > 0, hasRecordCounts = revivBinRecordCounts?.Length > 0;
            bool useRevivBinsPowerOf2 = enableRevivification; // may be overridden

            if (hasRecordSizes)
            {
                if (hasRecordCounts && revivBinRecordCounts.Length > 1 && revivBinRecordCounts.Length != revivBinRecordSizes.Length)
                    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.

View on GitHub (pinned to 951b0fc683)

Solutions

  1. If you want explicit counts, also provide explicit RevivBinRecordSizes — that path disables power-of-2 mode automatically.
  2. If you want power-of-2 bins, remove RevivBinRecordCounts entirely.

Example fix

// before: power-of-2 default + explicit counts conflict
options.EnableRevivification = true;
options.RevivBinRecordCounts = new[] { 100, 200 };

// after: provide sizes too, which switches off power-of-2
options.EnableRevivification = true;
options.RevivBinRecordSizes  = new[] { 64, 128 };
options.RevivBinRecordCounts = new[] { 100, 200 };
Defensive patterns

Strategy: validation

Validate before calling

void ValidateRevivCountsVsPowerOf2(int[] counts, bool enableReviv)
{
    // If counts are specified, sizes must also be present (which disables power-of-2).
    if (counts != null && counts.Length > 0 && enableReviv)
        // warn: user must also provide sizes to avoid this error
        throw new InvalidOperationException("RevivBinRecordCounts requires RevivBinRecordSizes (which disables power-of-2 bins).");
}

Try / catch

try
{
    options.Initialize(logger);
}
catch (Exception ex) when (ex.Message.Contains("powerof2"))
{
    logger.LogError("Revivification conflict: provide bin sizes with counts, or remove counts to use power-of-2.");
    throw;
}

Prevention

When it happens

Trigger: Setting EnableRevivification true (which enables power-of-2 bins by default) and also providing RevivBinRecordCounts. Happens when a user wants custom counts but does not realize the default scheme already defines its own bin layout.

Common situations: Adding RevivBinRecordCounts to a config where EnableRevivification was already true; misunderstanding that power-of-2 mode auto-manages bins.

Related errors


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