TechnitiumSoftware/DnsServer · error · DnsServerException

Failed to ask Secondary node to leave: the specified node do

Error message

Failed to ask Secondary node to leave: the specified node does not exist in the Cluster.

What it means

Thrown by AskSecondaryNodeToLeaveClusterAsync when the provided secondaryNodeId is not found in _clusterNodes. The TryGetValue at line 752 fails, meaning no node with that integer ID exists in the current cluster.

Source

Thrown at DnsServerCore/Cluster/ClusterManager.cs:753

            TriggerNotifyAllSecondaryNodes();

            //trigger NS and SOA update for member zones
            TriggerRecordUpdateForClusterCatalogMemberZones();

            return secondaryNode;
        }

        public async Task<ClusterNode> AskSecondaryNodeToLeaveClusterAsync(int secondaryNodeId)
        {
            if (!ClusterInitialized)
                throw new DnsServerException("Failed to ask Secondary node to leave: the Cluster is not initialized.");

            if (GetSelfNode().Type != ClusterNodeType.Primary)
                throw new DnsServerException("Failed to ask Secondary node to leave: only a Primary node can ask a Secondary node to leave the Cluster.");

            //find existing secondary node
            if (!_clusterNodes.TryGetValue(secondaryNodeId, out ClusterNode secondaryNode))
                throw new DnsServerException("Failed to ask Secondary node to leave: the specified node does not exist in the Cluster.");

            if (secondaryNode.Type == ClusterNodeType.Primary)
                throw new DnsServerException("Failed to ask Secondary node to leave: the specified node is the Cluster Primary node and cannot be removed.");

            //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.");

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Refresh the cluster node list and pass a currently-valid secondaryNodeId.
  2. Verify _clusterNodes.ContainsKey(secondaryNodeId) before calling.
  3. Handle the case where the node was already removed (treat as a no-op success).

Example fix

// before
await _clusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);
// after
if (!_clusterManager.ClusterNodes.Any(n => n.Key == nodeId))
    return; // node already gone — nothing to do
await _clusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);
Defensive patterns

Strategy: validation

Validate before calling

// Verify the node exists before asking it to leave
if (!_dnsWebService.ClusterManager.ClusterNodes.Any(n => n.Key == nodeId))
    return; // node already gone — nothing to do
await _dnsWebService.ClusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);

Type guard

static bool NodeExists(ClusterManager cm, int nodeId)
    => cm.ClusterNodes.Any(n => n.Key == nodeId);

Try / catch

try
{
    await _clusterManager.AskSecondaryNodeToLeaveClusterAsync(nodeId);
}
catch (DnsServerException ex) when (ex.Message.Contains("does not exist in the Cluster"))
{
    // node already removed — treat as idempotent success
}

Prevention

When it happens

Trigger: AskSecondaryNodeToLeaveClusterAsync(secondaryNodeId) is called with an ID that does not match any key in the _clusterNodes dictionary. This happens when the ID is stale, wrong, or the node was already removed.

Common situations: Stale UI showing a node that was already deleted; client passing the wrong integer ID; race where the node was removed between the UI loading the list and the user clicking leave.

Related errors


AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13). Data as JSON: /api/errors/55375bc421be702a. Report an issue: GitHub.