{"record":{"id":"2db99b2febff488a","repo":"hashicorp/nomad","slug":"scaling-policy-delete-failed-v","errorCode":null,"errorMessage":"scaling policy delete failed: %v","messagePattern":"scaling policy delete failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":7215,"sourceCode":"// DeleteScalingPoliciesTxn is used to delete a set of scaling policies by ID.\nfunc (s *StateStore) DeleteScalingPoliciesTxn(index uint64, ids []string, txn *txn) error {\n\tif len(ids) == 0 {\n\t\treturn nil\n\t}\n\n\tfor _, id := range ids {\n\t\t// Lookup the scaling policy\n\t\texisting, err := txn.First(\"scaling_policy\", \"id\", id)\n\t\tif err != nil {\n\t\t\treturn fmt.Errorf(\"scaling policy lookup failed: %v\", err)\n\t\t}\n\t\tif existing == nil {\n\t\t\treturn fmt.Errorf(\"scaling policy not found\")\n\t\t}\n\n\t\t// Delete the scaling policy\n\t\tif err := txn.Delete(\"scaling_policy\", existing); err != nil {\n\t\t\treturn fmt.Errorf(\"scaling policy delete failed: %v\", err)\n\t\t}\n\t}\n\n\tif err := txn.Insert(\"index\", &IndexEntry{\"scaling_policy\", index}); err != nil {\n\t\treturn fmt.Errorf(\"index update failed: %v\", err)\n\t}\n\n\treturn nil\n}\n\n// ScalingPolicies returns an iterator over all the scaling policies\nfunc (s *StateStore) ScalingPolicies(ws memdb.WatchSet) (memdb.ResultIterator, error) {\n\ttxn := s.db.ReadTxn()\n\n\t// Walk the entire scaling_policy table\n\titer, err := txn.Get(\"scaling_policy\", \"id\")\n\tif err != nil {\n\t\treturn nil, err","sourceCodeStart":7197,"sourceCodeEnd":7233,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L7197-L7233","documentation":"After finding the scaling policy, DeleteScalingPolicy calls txn.Delete on the scaling_policy table; if the underlying memdb/MemDB transaction delete fails, the error is wrapped as \"scaling policy delete failed: %v\". This indicates an internal transaction problem, not a missing policy.","triggerScenarios":"A scaling policy delete RPC where the internal txn.Delete returns an error (e.g., invalid transaction state or store-level write failure).","commonSituations":"Rare internal state-store faults; typically surfaced alongside raft/apply errors or store corruption; effectively never caused by user input.","solutions":["Check the wrapped cause in the full error string/agent logs.","Retry the delete; the transaction may have aborted transiently.","If persistent, verify cluster health and consider restoring the state store from backup."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"var retriableErr *gomdb.ErrNotFound // inspect wrapped cause instead\nif strings.HasPrefix(err.Error(), \"scaling policy delete failed:\") {\n    // log wrapped cause, retry after backoff; escalate if persistent\n}","preventionTips":["Monitor Nomad server logs for repeated state-store write failures.","Keep the cluster healthy (raft quorum) before running state mutations."],"tags":["nomad","state-store","scaling-policy","transaction"],"backgroundTag":"state-store-write-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"}