{"record":{"id":"e35753e68c1394e9","repo":"dotnet/orleans","slug":"could-not-find-table-version-row-or-found-too-many","errorCode":null,"errorMessage":"Could not find table version row or found too many entries. Was looking for key {0}, found = {1}","messagePattern":"Could not find table version row or found too many entries\\. Was looking for key (.+?), found = (.+?)","errorType":"exception","errorClass":"KeyNotFoundException","httpStatus":null,"severity":"error","filePath":"src/Azure/Orleans.Clustering.AzureStorage/OrleansSiloInstanceManager.cs","lineNumber":253,"sourceCode":"            else\n            {\n                var tasks = new List<Task>();\n                foreach (var batch in entriesList.BatchIEnumerable(this.storagePolicyOptions.MaxBulkUpdateRows))\n                {\n                    tasks.Add(storage.DeleteTableEntriesAsync(batch));\n                }\n                await Task.WhenAll(tasks);\n            }\n        }\n\n        internal async Task<List<(SiloInstanceTableEntry, string)>> FindSiloEntryAndTableVersionRow(SiloAddress siloAddress)\n        {\n            string rowKey = SiloInstanceTableEntry.ConstructRowKey(siloAddress);\n\n            var filter = TableClient.CreateQueryFilter($\"(PartitionKey eq {DeploymentId}) and ((RowKey eq {rowKey}) or (RowKey eq {SiloInstanceTableEntry.TABLE_VERSION_ROW}))\");\n            var queryResults = await storage.ReadTableEntriesAndEtagsAsync(filter);\n            if (queryResults.Count < 1 || queryResults.Count > 2)\n                throw new KeyNotFoundException(string.Format(\"Could not find table version row or found too many entries. Was looking for key {0}, found = {1}\", siloAddress, Utils.EnumerableToString(queryResults)));\n\n            var numTableVersionRows = 0;\n            foreach (var entry in queryResults)\n            {\n                if (entry.Item1.RowKey == SiloInstanceTableEntry.TABLE_VERSION_ROW)\n                {\n                    numTableVersionRows++;\n                }\n            }\n\n            if (numTableVersionRows < 1)\n                throw new KeyNotFoundException(string.Format(\"Did not read table version row. Read = {0}\", Utils.EnumerableToString(queryResults)));\n\n            if (numTableVersionRows > 1)\n                throw new KeyNotFoundException(string.Format(\"Read {0} table version rows, while was expecting only 1. Read = {1}\", numTableVersionRows, Utils.EnumerableToString(queryResults)));\n\n            return queryResults;\n        }","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/dotnet/orleans/blob/fca799fa70ecb6ad975224271703ca43221f58de/src/Azure/Orleans.Clustering.AzureStorage/OrleansSiloInstanceManager.cs#L235-L271","documentation":"Thrown by OrleansSiloInstanceManager.FindSiloEntryAndTableVersionRow when the Azure Table query for a silo row plus the version row returns fewer than 1 or more than 2 entities. A correct read yields exactly the silo row and the version row; anything else means the silo is not registered or the partition is inconsistent. KeyNotFoundException includes the requested siloAddress and the rows actually found.","triggerScenarios":"Reading a specific silo's membership entry when the silo has not yet registered (count 0), or when duplicate/version anomalies produced >2 rows. The query filters PartitionKey=DeploymentId AND (RowKey=silo OR RowKey=Version).","commonSituations":"Querying a silo before it has inserted its row (startup race); the silo was deleted/unregistered but another silo still references it; duplicated silo rows from a retry storm; partition key mismatch (wrong DeploymentId).","solutions":["Confirm the silo has registered: wait for RegisterSiloInstance to complete before reading, or retry with backoff.","Verify the DeploymentId matches the cluster the silo belongs to.","Inspect the partition for duplicate/corrupt rows and remove extras.","Handle KeyNotFoundException gracefully if the lookup is best-effort (e.g. gossip), rather than treating it as fatal."],"exampleFix":"// before\nvar rows = await manager.FindSiloEntryAndTableVersionRow(addr); // throws if not registered\n\n// after\ntry { var rows = await manager.FindSiloEntryAndTableVersionRow(addr); }\ncatch (KeyNotFoundException) { /* silo not yet registered; retry or skip */ }","handlingStrategy":"try-catch","validationCode":"// before reading a specific silo, confirm it is registered:\nvar entries = await manager.FindAllSiloEntries();\nbool registered = entries.Any(e => e.Entity.RowKey == SiloInstanceTableEntry.ConstructRowKey(addr));\nif (!registered) { /* skip or wait */ }","typeGuard":null,"tryCatchPattern":"try { var rows = await manager.FindSiloEntryAndTableVersionRow(addr); }\ncatch (KeyNotFoundException) { /* silo not registered or partition inconsistent; retry or skip */ }","preventionTips":["Wait for RegisterSiloInstance to complete before reading a silo entry.","Verify DeploymentId matches the target cluster.","Treat KeyNotFoundException as non-fatal for best-effort lookups."],"tags":["csharp","dotnet","orleans","azure-storage","membership","not-found"],"backgroundTag":null,"analyzedSha":"fca799fa70ecb6ad975224271703ca43221f58de","analyzedAt":"2026-08-13T19:55:57.938Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}