{"record":{"id":"1d5086a4deb5c9f0","repo":"nats-io/nats-server","slug":"lame-duck-grace-period-v-should-be-strictly-low","errorCode":null,"errorMessage":"lame duck grace period (%v) should be strictly lower than lame duck duration (%v)","messagePattern":"lame duck grace period \\((.+?)\\) should be strictly lower than lame duck duration \\((.+?)\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"server/server.go","lineNumber":1168,"sourceCode":"\t\t}\n\t}\n\treturn nil\n}\n\nfunc validatePinnedCerts(pinned PinnedCertSet) error {\n\tre := regexp.MustCompile(\"^[a-f0-9]{64}$\")\n\tfor certId := range pinned {\n\t\tentry := strings.ToLower(certId)\n\t\tif !re.MatchString(entry) {\n\t\t\treturn fmt.Errorf(\"error parsing 'pinned_certs' key %s does not look like lower case hex-encoded sha256 of DER encoded SubjectPublicKeyInfo\", entry)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateOptions(o *Options) error {\n\tif o.LameDuckDuration > 0 && o.LameDuckGracePeriod >= o.LameDuckDuration {\n\t\treturn fmt.Errorf(\"lame duck grace period (%v) should be strictly lower than lame duck duration (%v)\",\n\t\t\to.LameDuckGracePeriod, o.LameDuckDuration)\n\t}\n\tif int64(o.MaxPayload) > o.MaxPending {\n\t\treturn fmt.Errorf(\"max_payload (%v) cannot be higher than max_pending (%v)\",\n\t\t\to.MaxPayload, o.MaxPending)\n\t}\n\tif o.ServerName != _EMPTY_ && strings.Contains(o.ServerName, \" \") {\n\t\treturn errors.New(\"server name cannot contain spaces\")\n\t}\n\t// Check that the trust configuration is correct.\n\tif err := validateTrustedOperators(o); err != nil {\n\t\treturn err\n\t}\n\t// Check on leaf nodes which will require a system\n\t// account when gateways are also configured.\n\tif err := validateLeafNode(o); err != nil {\n\t\treturn err\n\t}","sourceCodeStart":1150,"sourceCodeEnd":1186,"githubUrl":"https://github.com/nats-io/nats-server/blob/3a66a489d262bf89b71a71c955c94920394532f3/server/server.go#L1150-L1186","documentation":"validateOptions rejects the config when lame_duck_grace_period is greater than or equal to lame_duck_duration (and duration > 0): the grace period must fit strictly inside the lame duck duration, otherwise the shutdown sequencing (grace then close) cannot be scheduled. Both values are printed for comparison.","triggerScenarios":"Thrown at server/server.go:1168 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Lower lame_duck_grace_period below lame_duck_duration (strictly less than)","Scale both values together, e.g. duration 30s with grace 10s","Omit grace period if the default relative value is acceptable"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"3a66a489d262bf89b71a71c955c94920394532f3","analyzedAt":"2026-09-02T04:41:54.247Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}