{"record":{"id":"2001d1a9a03ea1fa","repo":"TechnitiumSoftware/DnsServer","slug":"failed-to-update-secondary-node-the-specified-nod","errorCode":null,"errorMessage":"Failed to update Secondary node: the specified node does not exist in the Cluster.","messagePattern":"Failed to update Secondary node: the specified node does not exist in the Cluster\\.","errorType":"exception","errorClass":"DnsServerException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Cluster/ClusterManager.cs","lineNumber":827,"sourceCode":"\n            //trigger NS and SOA update for member zones\n            TriggerRecordUpdateForClusterCatalogMemberZones();\n\n            return secondaryNode;\n        }\n\n        public ClusterNode UpdateSecondaryNode(int secondaryNodeId, Uri secondaryNodeUrl, IReadOnlyList<IPAddress> secondaryNodeIpAddresses, X509Certificate2 secondaryNodeCertificate)\n        {\n            if (!ClusterInitialized)\n                throw new DnsServerException(\"Failed to update Secondary node: the Cluster is not initialized.\");\n\n            if (GetSelfNode().Type != ClusterNodeType.Primary)\n                throw new DnsServerException(\"Failed to update Secondary node: only a Primary node can update a Secondary node's details in the Cluster.\");\n\n            IReadOnlyDictionary<int, ClusterNode> clusterNodes = _clusterNodes;\n\n            if (!clusterNodes.TryGetValue(secondaryNodeId, out ClusterNode secondaryNode))\n                throw new DnsServerException(\"Failed to update Secondary node: the specified node does not exist in the Cluster.\");\n\n            if (secondaryNode.Type != ClusterNodeType.Secondary)\n                throw new DnsServerException(\"Failed to update Secondary node: the specified node to update must be a Secondary node.\");\n\n            //validate for duplicate names\n            foreach (KeyValuePair<int, ClusterNode> clusterNode in clusterNodes)\n            {\n                if (clusterNode.Key == secondaryNodeId)\n                    continue; //skip self\n\n                if (clusterNode.Value.Name.Equals(secondaryNodeUrl.Host, StringComparison.OrdinalIgnoreCase))\n                    throw new DnsServerException(\"Failed to update Secondary node: A node with the same DNS Server Domain Name already exists in the Cluster. Please try again after changing the Secondary node's DNS Server Domain Name.\");\n            }\n\n            bool secondaryNodeDomainChanged = !secondaryNode.Name.Equals(secondaryNodeUrl.Host, StringComparison.OrdinalIgnoreCase);\n\n            //find existing record TTL values\n            FindExistingRecordTtlValues(out uint nsTtl, out uint aTtl);","sourceCodeStart":809,"sourceCodeEnd":845,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Cluster/ClusterManager.cs#L809-L845","documentation":"UpdateSecondaryNode looked up secondaryNodeId in the cluster node table and found nothing. The ID supplied does not correspond to any current cluster member.","triggerScenarios":"Passing a stale or already-removed node ID; using an array index instead of the node's actual ID; the node was deleted by a concurrent operation before this call ran.","commonSituations":"Cached node list gone stale; off-by-one between list position and node ID; a race where another admin deleted the node first.","solutions":["Refresh the node list from the cluster and use a current Secondary node ID","Confirm the ID exists immediately before calling, especially under concurrency","Distinguish node ID (int) from list index"],"exampleFix":"// before\nclusterManager.UpdateSecondaryNode(maybeStaleId, url, ips, cert);\n\n// after\nvar node = clusterState.ClusterNodes\n    .FirstOrDefault(n => n.Id == id && n.Type == ClusterNodeType.Secondary);\nif (node is null) throw new ArgumentException(\"Secondary node not found; refresh the node list.\");\nclusterManager.UpdateSecondaryNode(node.Id, url, ips, cert);","handlingStrategy":"validation","validationCode":"if (!clusterState.ClusterNodes.Any(n => n.Id == secondaryNodeId))\n    return NotFound(\"Secondary node ID does not exist.\");\nclusterManager.UpdateSecondaryNode(secondaryNodeId, url, ips, cert);","typeGuard":null,"tryCatchPattern":"catch (DnsServerException ex) when (ex.Message.Contains(\"does not exist in the Cluster\"))\n{ /* refresh node list and re-prompt */ }","preventionTips":["Never cache node IDs across long-lived sessions - re-fetch cluster state","Validate the ID against the live node table right before mutating"],"tags":["cluster","stale-data","validation","dns-server"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}