{"record":{"id":"490d883bdf3bb95d","repo":"microsoft/garnet","slug":"incompatible-revivification-record-size-and-count","errorCode":null,"errorMessage":"Incompatible revivification record size and count cardinality.","messagePattern":"Incompatible revivification record size and count cardinality\\.","errorType":"validation","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"libs/host/Configuration/Options.cs","lineNumber":796,"sourceCode":"                     listenEp.Address.Equals(IPAddress.IPv6Any))))\n                    throw new GarnetException(\"Cluster announce endpoint does not match list of listen endpoints provided!\");\n            }\n\n            if (!string.IsNullOrEmpty(UnixSocketPath))\n                endpoints = [.. endpoints, new UnixDomainSocketEndPoint(UnixSocketPath)];\n\n            // Unix file permission octal to UnixFileMode\n            var unixSocketPermissions = (UnixFileMode)Convert.ToInt32(UnixSocketPermission.ToString(), 8);\n\n            var revivBinRecordSizes = this.RevivBinRecordSizes?.ToArray();\n            var revivBinRecordCounts = this.RevivBinRecordCounts?.ToArray();\n            bool hasRecordSizes = revivBinRecordSizes?.Length > 0, hasRecordCounts = revivBinRecordCounts?.Length > 0;\n            bool useRevivBinsPowerOf2 = enableRevivification; // may be overridden\n\n            if (hasRecordSizes)\n            {\n                if (hasRecordCounts && revivBinRecordCounts.Length > 1 && revivBinRecordCounts.Length != revivBinRecordSizes.Length)\n                    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.\");","sourceCodeStart":778,"sourceCodeEnd":814,"githubUrl":"https://github.com/microsoft/garnet/blob/951b0fc6838721f89d102c2bbe1b914e8d39d700/libs/host/Configuration/Options.cs#L778-L814","documentation":"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).","triggerScenarios":"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].","commonSituations":"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.","solutions":["Make RevivBinRecordCounts the same length as RevivBinRecordSizes, or provide a single count value to apply uniformly.","Audit both arrays entry-by-entry in the config to find the mismatch.","Remove RevivBinRecordCounts entirely to use default counts."],"exampleFix":"// before\noptions.RevivBinRecordSizes  = new[] { 64, 128, 256 };\noptions.RevivBinRecordCounts = new[] { 100, 200 };\n\n// after\noptions.RevivBinRecordSizes  = new[] { 64, 128, 256 };\noptions.RevivBinRecordCounts = new[] { 100, 200, 300 };","handlingStrategy":"validation","validationCode":"void ValidateRevivBins(int[] sizes, int[] counts)\n{\n    if (counts != null && counts.Length > 1 && sizes != null && counts.Length != sizes.Length)\n        throw new InvalidOperationException($\"RevivBinRecordCounts length ({counts.Length}) must match RevivBinRecordSizes length ({sizes?.Length ?? 0}).\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    options.Initialize(logger);\n}\ncatch (Exception ex) when (ex.Message.Contains(\"cardinality\"))\n{\n    logger.LogError(\"Revivification bin sizes and counts have mismatched lengths.\");\n    throw;\n}","preventionTips":["When editing revivification arrays, update sizes and counts together.","Use a config helper that builds both arrays from a single list of (size, count) pairs."],"tags":["config","revivification","validation","arrays","options","cardinality"],"backgroundTag":null,"analyzedSha":"951b0fc6838721f89d102c2bbe1b914e8d39d700","analyzedAt":"2026-08-13T19:01:32.939Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}