{"record":{"id":"cab0ac948254d4f8","repo":"TechnitiumSoftware/DnsServer","slug":"serve-stale-reset-ttl-must-be-between-serve-stale","errorCode":null,"errorMessage":"Serve stale reset TTL must be between {SERVE_STALE_MIN_RESET_TTL} and {SERVE_STALE_MAX_RESET_TTL} seconds. Recommended value is 30 seconds.","messagePattern":"Serve stale reset TTL must be between (.+?) and (.+?) seconds\\. Recommended value is 30 seconds\\.","errorType":"validation","errorClass":"ArgumentOutOfRangeException","httpStatus":null,"severity":"error","filePath":"DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs","lineNumber":1225,"sourceCode":"                        return null; //no cached delegation found\n                }\n            }\n\n            //no cached delegation found\n            return null;\n        }\n\n        #endregion\n\n        #region properties\n\n        public uint ServeStaleResetTtl\n        {\n            get { return _serveStaleResetTtl; }\n            set\n            {\n                if ((value < SERVE_STALE_MIN_RESET_TTL) || (value > SERVE_STALE_MAX_RESET_TTL))\n                    throw new ArgumentOutOfRangeException(nameof(ServeStaleResetTtl), \"Serve stale reset TTL must be between \" + SERVE_STALE_MIN_RESET_TTL + \" and \" + SERVE_STALE_MAX_RESET_TTL + \" seconds. Recommended value is 30 seconds.\");\n\n                _serveStaleResetTtl = value;\n            }\n        }\n\n        public long MaximumEntries\n        {\n            get { return _maximumEntries; }\n            set\n            {\n                if (value < 0)\n                    throw new ArgumentOutOfRangeException(nameof(MaximumEntries), \"Invalid cache maximum entries value. Valid range is 0 and above.\");\n\n                _maximumEntries = value;\n            }\n        }\n\n        public long TotalEntries","sourceCodeStart":1207,"sourceCodeEnd":1243,"githubUrl":"https://github.com/TechnitiumSoftware/DnsServer/blob/d0484b6c1e7439cdc53d67d81e9c876cda2ad756/DnsServerCore/Dns/ZoneManagers/CacheZoneManager.cs#L1207-L1243","documentation":"Thrown by the ServeStaleResetTtl property setter when value is below SERVE_STALE_MIN_RESET_TTL or above SERVE_STALE_MAX_RESET_TTL. Serve-stale (serving expired records while refreshing) uses this reset TTL; the bounds keep behavior sane. The recommended value of 30 seconds is noted in the message.","triggerScenarios":"Setting ServeStaleResetTtl to 0, a sub-minimum value, or above the maximum; unit confusion (passing milliseconds into a seconds field).","commonSituations":"Tuning serve-stale and entering an out-of-range number; config import with an invalid value; assuming 0 disables it (it does not - the field has a positive minimum).","solutions":["Set ServeStaleResetTtl to a value within [SERVE_STALE_MIN_RESET_TTL, SERVE_STALE_MAX_RESET_TTL]; use the recommended 30 seconds if unsure.","Confirm the unit is seconds, not milliseconds.","Read the named constants' values from the class to know the exact bounds before configuring."],"exampleFix":"// before\n_cacheZoneManager.ServeStaleResetTtl = 0; // below min -> throws\n// after\n_cacheZoneManager.ServeStaleResetTtl = 30; // recommended value (seconds)","handlingStrategy":"validation","validationCode":"uint ttl = value;\nif (ttl < CacheZoneManager.SERVE_STALE_MIN_RESET_TTL || ttl > CacheZoneManager.SERVE_STALE_MAX_RESET_TTL)\n    ttl = 30u; // recommended default\ncacheZoneManager.ServeStaleResetTtl = ttl;","typeGuard":"static bool IsValidServeStaleResetTtl(uint v) => v >= CacheZoneManager.SERVE_STALE_MIN_RESET_TTL && v <= CacheZoneManager.SERVE_STALE_MAX_RESET_TTL;","tryCatchPattern":"try { cacheZoneManager.ServeStaleResetTtl = value; }\ncatch (ArgumentOutOfRangeException) { cacheZoneManager.ServeStaleResetTtl = 30u; }","preventionTips":["Reference the class constants for exact bounds rather than guessing.","Use the recommended 30 seconds when in doubt.","Remember the unit is seconds, not milliseconds.","Clamp config values at the UI/config boundary."],"tags":["dns","cache","serve-stale","validation","configuration"],"backgroundTag":null,"analyzedSha":"d0484b6c1e7439cdc53d67d81e9c876cda2ad756","analyzedAt":"2026-08-13T22:57:35.508Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}