{"record":{"id":"43ba87df9c3518c3","repo":"hashicorp/nomad","slug":"unable-to-update-job-recommendations-v","errorCode":null,"errorMessage":"unable to update job recommendations: %v","messagePattern":"unable to update job recommendations: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":1896,"sourceCode":"\t\tif updated != nil {\n\t\t\tjob = updated.(*structs.Job)\n\t\t}\n\t}\n\n\tif err := s.updateSummaryWithJob(index, job, txn); err != nil {\n\t\treturn fmt.Errorf(\"unable to create job summary: %v\", err)\n\t}\n\n\tif err := s.upsertJobVersion(index, job, txn); err != nil {\n\t\treturn fmt.Errorf(\"unable to upsert job into job_version table: %v\", err)\n\t}\n\n\tif err := s.updateJobScalingPolicies(index, job, txn); err != nil {\n\t\treturn fmt.Errorf(\"unable to update job scaling policies: %v\", err)\n\t}\n\n\tif err := s.updateJobRecommendations(index, txn, existingJob, job); err != nil {\n\t\treturn fmt.Errorf(\"unable to update job recommendations: %v\", err)\n\t}\n\n\tif err := s.updateJobCSIPlugins(index, job, existingJob, txn); err != nil {\n\t\treturn fmt.Errorf(\"unable to update job csi plugins: %v\", err)\n\t}\n\n\tif err := s.updateJobSubmission(index, sub, job.Namespace, job.ID, job.Version, txn); err != nil {\n\t\treturn fmt.Errorf(\"unable to update job submission: %v\", err)\n\t}\n\n\tif err := s.updatePreservedValues(job, existingJob, req); err != nil {\n\t\treturn fmt.Errorf(\"unable to update preserved values: %v\", err)\n\t}\n\n\t// Insert the job\n\tif err := txn.Insert(\"jobs\", job); err != nil {\n\t\treturn fmt.Errorf(\"job insert failed: %v\", err)\n\t}","sourceCodeStart":1878,"sourceCodeEnd":1914,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L1878-L1914","documentation":"UpsertJob failed while updating job recommendations via updateJobRecommendations, which reconciles stored recommendations against the newly submitted job's task group resources. The failure wraps the internal error and aborts the registration transaction.","triggerScenarios":"Registering a job on a cluster using Nomad's Recommendations feature (enterprise/optimize) where recommendation table updates fail inside the transaction.","commonSituations":"Clusters using the optimizer/recommendations API where existing recommendations reference task groups that were renamed/removed in the new job spec.","solutions":["Read the wrapped cause from server logs","Retry the job registration after confirming server health","Delete stale recommendations for the job before re-registering","Disable/remove the recommendations workflow temporarily if it blocks critical registrations"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check for stale recommendations before re-registering a restructured job\nrecs, _, err := client.Recommendations().List(&nomad.QueryOptions{Namespace: job.Namespace})\nif err == nil {\n  for _, r := range recs {\n    if r.Job == job.ID {\n      fmt.Printf(\"stale recommendation for %s/%s\\n\", r.Job, r.TaskGroup)\n    }\n  }\n}","typeGuard":"func isRecommendationError(err error) bool {\n  return err != nil && strings.Contains(err.Error(), \"job recommendations\")\n}","tryCatchPattern":"_, err := client.Jobs().Register(job, nil, nil, nil)\nif isRecommendationError(err) {\n  // retry; if persistent, apply/delete pending recommendations first\n  _, err = client.Jobs().Register(job, nil, nil, nil)\n}\nreturn err","preventionTips":["Apply or delete outstanding recommendations before restructuring task groups","Avoid renaming task groups on jobs with stored recommendations","Only enable recommendations (optimizer) on consistent cluster versions","Monitor optimizer API errors in server logs"],"tags":["nomad","state-store","recommendations"],"backgroundTag":"job-recommendation-sync-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"}