TechnitiumSoftware/DnsServer · warning · InvalidDataException

HourlyStats version not supported.

Error message

HourlyStats version not supported.

What it means

Thrown by the HourlyStats(BinaryReader) constructor when the version byte (read after the 'HS' magic) is not 1. Only version 1 is supported; it reads 60 per-minute StatCounter entries and merges them into the hour total. The default rejects any other version so a future-format or corrupt file fails instead of being misread.

Source

Thrown at DnsServerCore/Dns/StatsManager.cs:1763

                    throw new InvalidDataException("HourlyStats format is invalid.");

                byte version = bR.ReadByte();
                switch (version)
                {
                    case 1:
                        _hourStat = new StatCounter();
                        _hourStat.Lock();

                        for (int i = 0; i < _minuteStats.Length; i++)
                        {
                            _minuteStats[i] = new StatCounter(bR);
                            _hourStat.Merge(_minuteStats[i]);
                        }

                        break;

                    default:
                        throw new InvalidDataException("HourlyStats version not supported.");
                }
            }

            #endregion

            #region public

            public void UpdateStat(DateTime dateTime, StatCounter minuteStat)
            {
                if (ReferenceEquals(this, Empty))
                    return;

                if (!minuteStat.IsLocked)
                    throw new DnsServerException("StatCounter must be locked.");

                _hourStat.Merge(minuteStat);
                _minuteStats[dateTime.Minute] = minuteStat;
            }

View on GitHub (pinned to d0484b6c1e)

Solutions

  1. Delete the offending hourly .stat file; the hour will simply be missing from historical stats going forward.
  2. If reproducing a downgrade, upgrade to the build that wrote the file to drain old stats, then downgrade.
  3. Keep one stats folder per server build; do not share across versions.
Defensive patterns

Strategy: fallback

Try / catch

try { hourly = new HourlyStats(bR); }
catch (InvalidDataException ex) when (ex.Message == "HourlyStats version not supported.")
{ hourly = HourlyStats.Empty; }

Prevention

When it happens

Trigger: Reading an hourly .stat file whose version byte is not 1, after the 'HS' magic passed. Caused by a file written by a newer build with a different HourlyStats layout, a truncated stream, or corruption of the version byte.

Common situations: Server downgrade across a HourlyStats version bump; corrupt .stat file; mixing stats files from different server versions in one stats folder.

Related errors


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