microsoft/garnet · error · Exception

Incompatible revivification record size and count cardinalit

Error message

Incompatible revivification record size and count cardinality.

What it means

Generic Exception thrown during Options.Initialize revivification validation when RevivBinRecordCounts is provided with more than one element but its length does not equal RevivBinRecordSizes.Length. The two arrays are parallel: each bin has a size and a count, so their cardinalities must match (a single count is allowed as a uniform default, hence the '> 1' guard).

Source

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

                     listenEp.Address.Equals(IPAddress.IPv6Any))))
                    throw new GarnetException("Cluster announce endpoint does not match list of listen endpoints provided!");
            }

            if (!string.IsNullOrEmpty(UnixSocketPath))
                endpoints = [.. endpoints, new UnixDomainSocketEndPoint(UnixSocketPath)];

            // Unix file permission octal to UnixFileMode
            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.");

View on GitHub (pinned to 951b0fc683)

Solutions

  1. Make RevivBinRecordCounts the same length as RevivBinRecordSizes, or provide a single count value to apply uniformly.
  2. Audit both arrays entry-by-entry in the config to find the mismatch.
  3. Remove RevivBinRecordCounts entirely to use default counts.

Example fix

// before
options.RevivBinRecordSizes  = new[] { 64, 128, 256 };
options.RevivBinRecordCounts = new[] { 100, 200 };

// after
options.RevivBinRecordSizes  = new[] { 64, 128, 256 };
options.RevivBinRecordCounts = new[] { 100, 200, 300 };
Defensive patterns

Strategy: validation

Validate before calling

void ValidateRevivBins(int[] sizes, int[] counts)
{
    if (counts != null && counts.Length > 1 && sizes != null && counts.Length != sizes.Length)
        throw new InvalidOperationException($"RevivBinRecordCounts length ({counts.Length}) must match RevivBinRecordSizes length ({sizes?.Length ?? 0}).");
}

Try / catch

try
{
    options.Initialize(logger);
}
catch (Exception ex) when (ex.Message.Contains("cardinality"))
{
    logger.LogError("Revivification bin sizes and counts have mismatched lengths.");
    throw;
}

Prevention

When it happens

Trigger: Configuring revivification bins with RevivBinRecordSizes having N entries and RevivBinRecordCounts having M entries where M > 1 and M != N. E.g., sizes = [64,128,256] but counts = [100,200].

Common situations: Hand-editing the revivification arrays in the config file and mismatching the number of entries; partial edit where a size or count was added/removed on one side only.

Related errors


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