{"record":{"id":"7f574d939c1c3127","repo":"hashicorp/nomad","slug":"unable-to-query-job-v","errorCode":null,"errorMessage":"unable to query job: %v","messagePattern":"unable to query job: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":6065,"sourceCode":"// or inserted\nfunc (s *StateStore) updateSummaryWithAlloc(index uint64, alloc *structs.Allocation,\n\texistingAlloc *structs.Allocation, txn *txn) error {\n\n\t// We don't have to update the summary if the job is missing\n\tif alloc.Job == nil {\n\t\treturn nil\n\t}\n\n\tsummaryRaw, err := txn.First(\"job_summary\", \"id\", alloc.Namespace, alloc.JobID)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to lookup job summary for job id %q in namespace %q: %v\", alloc.JobID, alloc.Namespace, err)\n\t}\n\n\tif summaryRaw == nil {\n\t\t// Check if the job is de-registered\n\t\trawJob, err := txn.First(\"jobs\", \"id\", alloc.Namespace, alloc.JobID)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"unable to query job: %v\", err)\n\t\t}\n\n\t\t// If the job is de-registered then we skip updating it's summary\n\t\tif rawJob == nil {\n\t\t\treturn nil\n\t\t}\n\n\t\treturn fmt.Errorf(\"job summary for job %q in namespace %q is not present\", alloc.JobID, alloc.Namespace)\n\t}\n\n\t// Get a copy of the existing summary\n\tjobSummary := summaryRaw.(*structs.JobSummary).Copy()\n\n\t// Not updating the job summary because the allocation doesn't belong to the\n\t// currently registered job\n\tif jobSummary.CreateIndex != alloc.Job.CreateIndex {\n\t\treturn nil\n\t}","sourceCodeStart":6047,"sourceCodeEnd":6083,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L6047-L6083","documentation":"Wraps a txn.First error when checking whether the job still exists in the jobs table after its summary was missing. This fallback exists to distinguish a deregistered (GC'd) job from a real inconsistency; the error is a read failure, not a missing job.","triggerScenarios":"Alloc summary update where the job_summary row is nil and the follow-up txn.First(\"jobs\", \"id\", alloc.Namespace, alloc.JobID) returns a memdb error.","commonSituations":"Alloc updates for jobs that were just purged by job GC while allocs are still being updated; normally that path returns nil silently, errors indicate txn problems.","solutions":["Inspect the wrapped inner error","Retry; alloc reconciliation will re-run","If recurring, check for state store issues in server logs"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"if err != nil && strings.Contains(err.Error(), \"unable to query job\") {\n    // alloc reconciliation reruns periodically; safe to ignore and retry\n    return retryLater()\n}","preventionTips":["Avoid racing job purges with alloc updates in custom automation","Rely on Nomad's alloc reconciliation loop","Monitor GC activity against active deployments"],"tags":["nomad","state-store","alloc","gc"],"backgroundTag":"state-store-txn-lookup-failed","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"}