TechnitiumSoftware/DnsServer · critical · InvalidDataException
DNS Server Cluster config file format is invalid.
Error message
DNS Server Cluster config file format is invalid.
What it means
Thrown by ClusterManager.ReadConfigFrom(Stream) when the first two bytes of the stream are not the ASCII magic 'CL'. This is a file-format integrity check: every valid cluster config starts with 'CL'. A mismatch means the file is not a cluster config at all, is truncated, or is corrupt. ReadExactly(2) will itself throw if fewer than 2 bytes are available.
Source
Thrown at DnsServerCore/Cluster/ClusterManager.cs:363
}
}
catch (Exception ex)
{
_dnsWebService.LogManager.Write("DNS Server encountered an error while deleting the Cluster config file: " + configFile, ex);
}
if (_pendingSave)
{
_pendingSave = false;
_saveTimer.Change(Timeout.Infinite, Timeout.Infinite);
}
}
}
private void ReadConfigFrom(Stream s)
{
if (Encoding.ASCII.GetString(s.ReadExactly(2)) != "CL") //format
throw new InvalidDataException("DNS Server Cluster config file format is invalid.");
BinaryReader bR = new BinaryReader(s);
int version = bR.ReadByte();
switch (version)
{
case 1:
_clusterDomain = bR.ReadString();
_heartbeatRefreshIntervalSeconds = bR.ReadUInt16();
_heartbeatRetryIntervalSeconds = bR.ReadUInt16();
_configRefreshIntervalSeconds = bR.ReadUInt16();
_configRetryIntervalSeconds = bR.ReadUInt16();
_configLastSynced = s.ReadDateTime();
Dictionary<int, ClusterNode> clusterNodes = null;
int count = bR.ReadByte();
if (count > 0)View on GitHub (pinned to d0484b6c1e)
Solutions
- Restore the cluster config file from a known-good backup.
- Delete the corrupt config so the cluster can be re-initialized from scratch.
- Add a pre-check that reads the first two bytes and verifies 'CL' before invoking ReadConfigFrom.
Defensive patterns
Strategy: try-catch
Try / catch
try
{
clusterManager.Load();
}
catch (InvalidDataException ex) when (ex.Message.Contains("Cluster config file format is invalid"))
{
logger.LogCritical(ex, "Cluster config is corrupt; restoring from backup or re-initializing.");
RestoreClusterConfigFromBackup();
} Prevention
- Keep backups of the cluster config file.
- Use atomic writes (temp file + rename) for config saves to avoid truncation.
- Verify the 'CL' header before handing the stream to ReadConfigFrom.
When it happens
Trigger: Pointing the cluster config loader at a file that is empty, truncated, from a different feature, or otherwise missing the 'CL' header — e.g. a stale/partial save, a wrong file path, or a file replaced by an unrelated config.
Common situations: Config file half-written due to a crash during save; the path was misconfigured to point at a non-cluster config; disk/filesystem corruption; an interrupted copy leaving a zero-byte file.
Related errors
- DNS Server Cluster config version not supported.
- Invalid data or version not supported.
- DhcpServer scope file format is invalid.
- DNS Server config file format is invalid.
- Cannot add user to group: user can be member of max 255 grou
AI-assisted analysis of TechnitiumSoftware/DnsServer@d0484b6c1e (2026-08-13).
Data as JSON: /api/errors/353dc8a87b5af610.
Report an issue: GitHub.