{"record":{"id":"da8f120e9526a883","repo":"hashicorp/nomad","slug":"failed-to-update-job-stability-v","errorCode":null,"errorMessage":"failed to update job stability: %v","messagePattern":"failed to update job stability: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":4848,"sourceCode":"\t\tif copy.Status == structs.DeploymentStatusPaused || copy.Status == structs.DeploymentStatusRunning {\n\t\t\tdState.RequireProgressBy = time.Unix(0, u.UpdatedAt).Add(dState.ProgressDeadline)\n\t\t}\n\t}\n\n\t// Insert the deployment\n\tif err := txn.Insert(\"deployment\", copy); err != nil {\n\t\treturn err\n\t}\n\n\t// Update the index\n\tif err := txn.Insert(\"index\", &IndexEntry{\"deployment\", index}); err != nil {\n\t\treturn fmt.Errorf(\"index update failed: %v\", err)\n\t}\n\n\t// If the deployment is being marked as complete, set the job to stable.\n\tif copy.Status == structs.DeploymentStatusSuccessful {\n\t\tif err := s.updateJobStabilityImpl(index, copy.Namespace, copy.JobID, copy.JobVersion, true, txn); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to update job stability: %v\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// UpdateJobStability updates the stability of the given job and version to the\n// desired status.\nfunc (s *StateStore) UpdateJobStability(index uint64, namespace, jobID string, jobVersion uint64, stable bool) error {\n\ttxn := s.db.WriteTxn(index)\n\tdefer txn.Abort()\n\n\tif err := s.updateJobStabilityImpl(index, namespace, jobID, jobVersion, stable, txn); err != nil {\n\t\treturn err\n\t}\n\n\treturn txn.Commit()\n}","sourceCodeStart":4830,"sourceCodeEnd":4866,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L4830-L4866","documentation":"When a deployment is marked successful, the state store also flips the parent job to stable via updateJobStabilityImpl. This error wraps any failure from that stability update, aborting the deployment status update so the job's stable flag never diverges from the deployment's terminal status.","triggerScenarios":"UpsertDeploymentStatusUpdate called with DeploymentStatusSuccessful for a deployment whose job no longer exists, whose JobVersion/JobID/Namespace no longer match, or whose job-stability txn.Insert fails.","commonSituations":"Job was purged or garbage-collected between deployment creation and completion; namespace mismatch after job re-registration; concurrent job deregistration racing the deployment promotion.","solutions":["Verify the job still exists at copy.Namespace/copy.JobID with nomad job status before/after promoting the deployment","Check the wrapped error to distinguish 'job not found' from an index insert failure","Re-register the job or re-run the deployment if the job version was overwritten by a newer submit"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"job, err := client.Jobs().Info(deployment.JobID)\nif err != nil || job == nil {\n  return fmt.Errorf(\"job %s missing; cannot mark deployment stable\", deployment.JobID)\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n  if r := recover(); r != nil { log.Printf(\"stability update skipped: %v\", r) }\n}()","preventionTips":["Ensure the job exists and matches the deployment's JobVersion before promoting","Avoid purging jobs while deployments are active","Check namespace correctness in automation"],"tags":["nomad","state-store","deployment","job-stability"],"backgroundTag":"deployment-stability-update-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"}