{"record":{"id":"93e8145d794e62d9","repo":"hashicorp/nomad","slug":"periodic-dispatch-disabled","errorCode":null,"errorMessage":"periodic dispatch disabled","messagePattern":"periodic dispatch disabled","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/periodic.go","lineNumber":289,"sourceCode":"\t// Signal an update.\n\tselect {\n\tcase p.updateCh <- struct{}{}:\n\tdefault:\n\t}\n\n\tp.logger.Debug(\"deregistered periodic job\", \"job\", job.NamespacedID())\n\treturn nil\n}\n\n// ForceEval causes the periodic job to be evaluated immediately and returns the\n// subsequent eval.\nfunc (p *PeriodicDispatch) ForceEval(namespace, jobID string) (*structs.Evaluation, error) {\n\tp.l.Lock()\n\n\t// Do nothing if not enabled\n\tif !p.enabled {\n\t\tp.l.Unlock()\n\t\treturn nil, fmt.Errorf(\"periodic dispatch disabled\")\n\t}\n\n\ttuple := structs.NamespacedID{\n\t\tID:        jobID,\n\t\tNamespace: namespace,\n\t}\n\tjob, tracked := p.tracked[tuple]\n\tif !tracked {\n\t\tp.l.Unlock()\n\t\treturn nil, fmt.Errorf(\"can't force run non-tracked job %q (%s)\", jobID, namespace)\n\t}\n\n\tp.l.Unlock()\n\treturn p.createEval(job, time.Now().In(job.Periodic.GetLocation()))\n}\n\n// shouldRun returns whether the long lived run function should run.\nfunc (p *PeriodicDispatch) shouldRun() bool {","sourceCodeStart":271,"sourceCodeEnd":307,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/periodic.go#L271-L307","documentation":"PeriodicDispatch.ForceEval returns this when the periodic dispatcher is not enabled (the server is not the leader or periodic dispatch has been stopped). Force-run requests cannot be processed while disabled.","triggerScenarios":"Calling ForceEval when p.enabled is false — typically on a non-leader server, before the dispatcher starts, or after it was stopped during leadership loss/shutdown.","commonSituations":"Forcing a periodic job run right after a leader election where this server is no longer leader; calling ForceEval during server shutdown; restorePeriodicDispatcher racing with disable.","solutions":["Verify the targeted Nomad server is the current leader (use nomad monitor or query /v1/status/leader).","Retry the force-run against the leader or via the HTTP API, which forwards to the leader.","Wait for leader election to complete before forcing evaluations.","If persistent, check server logs for leadership flapping."],"exampleFix":"// before\neval, _ := dispatcher.ForceEval(ns, jobID)\n// after\neval, err := dispatcher.ForceEval(ns, jobID)\nif err != nil && strings.Contains(err.Error(), \"periodic dispatch disabled\") {\n    return retryAgainstLeader(ns, jobID)\n}","handlingStrategy":"retry","validationCode":"// Go: check leadership before ForceEval\nleader := statusAPI.Leader()\n// only proceed if this server reports itself as leader","typeGuard":null,"tryCatchPattern":"// Go\neval, err := d.ForceEval(ns, jobID)\nif err != nil && err.Error() == \"periodic dispatch disabled\" {\n    time.Sleep(backoff)\n    return d.ForceEval(ns, jobID) // retry or redirect to leader\n}","preventionTips":["Always route force-run requests through the leader-forwarding HTTP API","Wait for stable leadership before issuing force commands","Add retry with backoff around ForceEval"],"tags":["nomad","leadership","periodic-jobs","availability"],"backgroundTag":"not-leader","analyzedSha":"482b49bf1aec006f089bcfc7e632d8f6ac303e5e","analyzedAt":"2026-09-04T07:54:14.808Z","contentChangedAt":"2026-09-04T07:54:14.808Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}