hashicorp/nomad · error

unable to query job: %v

Error message

unable to query job: %v

What it means

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.

Source

Thrown at nomad/state/state_store.go:6065

// or inserted
func (s *StateStore) updateSummaryWithAlloc(index uint64, alloc *structs.Allocation,
	existingAlloc *structs.Allocation, txn *txn) error {

	// We don't have to update the summary if the job is missing
	if alloc.Job == nil {
		return nil
	}

	summaryRaw, err := txn.First("job_summary", "id", alloc.Namespace, alloc.JobID)
	if err != nil {
		return fmt.Errorf("unable to lookup job summary for job id %q in namespace %q: %v", alloc.JobID, alloc.Namespace, err)
	}

	if summaryRaw == nil {
		// Check if the job is de-registered
		rawJob, err := txn.First("jobs", "id", alloc.Namespace, alloc.JobID)
		if err != nil {
			return fmt.Errorf("unable to query job: %v", err)
		}

		// If the job is de-registered then we skip updating it's summary
		if rawJob == nil {
			return nil
		}

		return fmt.Errorf("job summary for job %q in namespace %q is not present", alloc.JobID, alloc.Namespace)
	}

	// Get a copy of the existing summary
	jobSummary := summaryRaw.(*structs.JobSummary).Copy()

	// Not updating the job summary because the allocation doesn't belong to the
	// currently registered job
	if jobSummary.CreateIndex != alloc.Job.CreateIndex {
		return nil
	}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Inspect the wrapped inner error
  2. Retry; alloc reconciliation will re-run
  3. If recurring, check for state store issues in server logs
Defensive patterns

Strategy: retry

Try / catch

if err != nil && strings.Contains(err.Error(), "unable to query job") {
    // alloc reconciliation reruns periodically; safe to ignore and retry
    return retryLater()
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/7f574d939c1c3127. Report an issue: GitHub.