TechnitiumSoftware/DnsServer · error · DnsServerException
Failed to delete Secondary node: the specified node does not
Error message
Failed to delete Secondary node: the specified node does not exist in the Cluster.
What it means
Thrown by DeleteSecondaryNode when the provided secondaryNodeId is not found in _clusterNodes. The TryGetValue on existingClusterNodes at line 775 fails, meaning no node with that integer ID currently exists in the cluster.
Source
Thrown at DnsServerCore/Cluster/ClusterManager.cs:776
//ask secondary node to leave the cluster
await secondaryNode.AskSecondaryNodeToLeaveClusterAsync();
return secondaryNode;
}
public ClusterNode DeleteSecondaryNode(int secondaryNodeId)
{
if (!ClusterInitialized)
throw new DnsServerException("Failed to delete Secondary node: the Cluster is not initialized.");
if (GetSelfNode().Type != ClusterNodeType.Primary)
throw new DnsServerException("Failed to delete Secondary node: only a Primary node can delete a Secondary node from the Cluster.");
//find existing secondary node
IReadOnlyDictionary<int, ClusterNode> existingClusterNodes = _clusterNodes;
if (!existingClusterNodes.TryGetValue(secondaryNodeId, out ClusterNode secondaryNode))
throw new DnsServerException("Failed to delete Secondary node: the specified node does not exist in the Cluster.");
if (secondaryNode.Type == ClusterNodeType.Primary)
throw new DnsServerException("Failed to delete Secondary node: the specified node is the Cluster Primary node and cannot be deleted.");
//delete secondary node from cluster nodes
Dictionary<int, ClusterNode> updatedClusterNodes = new Dictionary<int, ClusterNode>(existingClusterNodes.Count - 1);
foreach (KeyValuePair<int, ClusterNode> existingClusterNode in existingClusterNodes)
{
if (existingClusterNode.Key == secondaryNodeId)
continue;
updatedClusterNodes[existingClusterNode.Key] = existingClusterNode.Value;
}
IReadOnlyDictionary<int, ClusterNode> originalValue = Interlocked.CompareExchange(ref _clusterNodes, updatedClusterNodes, existingClusterNodes);
if (!ReferenceEquals(originalValue, existingClusterNodes))
throw new InvalidOperationException("Failed to delete Secondary node: please try again.");View on GitHub (pinned to d0484b6c1e)
Solutions
- Refresh the cluster node list and pass a currently-valid secondaryNodeId.
- Verify the node exists (_clusterNodes.ContainsKey) before calling.
- If the node is already gone, treat it as success (idempotent delete) rather than an error.
Example fix
// before
_clusterManager.DeleteSecondaryNode(nodeId);
// after — guard against stale/missing node
if (!_clusterManager.ClusterNodes.Any(n => n.Key == nodeId))
return; // already removed — idempotent no-op
_clusterManager.DeleteSecondaryNode(nodeId); Defensive patterns
Strategy: validation
Validate before calling
// Verify the node exists before deleting — treat missing as idempotent success
if (!_dnsWebService.ClusterManager.ClusterNodes.Any(n => n.Key == nodeId))
return; // already removed
_dnsWebService.ClusterManager.DeleteSecondaryNode(nodeId); Type guard
static bool NodeExists(ClusterManager cm, int nodeId)
=> cm.ClusterNodes.Any(n => n.Key == nodeId); Try / catch
try
{
_clusterManager.DeleteSecondaryNode(nodeId);
}
catch (DnsServerException ex) when (ex.Message.Contains("does not exist in the Cluster"))
{
// node already deleted — idempotent no-op
} Prevention
- Refresh the node list before issuing delete calls.
- Check ClusterNodes for the ID before calling DeleteSecondaryNode.
- Handle 'does not exist' as idempotent success in automation scripts.
When it happens
Trigger: DeleteSecondaryNode(secondaryNodeId) is called with an ID that does not match any key in the _clusterNodes dictionary. The node may have been already deleted, or the ID is simply wrong.
Common situations: Stale UI or client state showing a node that was already removed; double-delete attempt; wrong integer ID passed; race condition where another admin removed the node between the list refresh and the delete call.
Related errors
- Failed to ask Secondary node to leave: the specified node do
- Failed to delete Secondary node: the Cluster is not initiali
- Failed to delete Secondary node: only a Primary node can del
- Failed to update Primary node: the specified Primary node ID
- At least one parameter must be provided.
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/935adfcebcafa9b5.
Report an issue: GitHub.