{"record":{"id":"9794ca308e00793a","repo":"hashicorp/nomad","slug":"scaling-policy-lookup-failed-v","errorCode":null,"errorMessage":"scaling_policy lookup failed: %v","messagePattern":"scaling_policy lookup failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"nomad/state/state_store.go","lineNumber":7333,"sourceCode":"\t\td, ok := raw.(*structs.ScalingPolicy)\n\t\tif !ok {\n\t\t\treturn true\n\t\t}\n\n\t\treturn d.Target[structs.ScalingTargetJob] != jobID\n\t}\n\n\t// Wrap the iterator in a filter\n\twrap := memdb.NewFilterIterator(iter, filter)\n\treturn wrap, nil\n}\n\nfunc (s *StateStore) ScalingPolicyByID(ws memdb.WatchSet, id string) (*structs.ScalingPolicy, error) {\n\ttxn := s.db.ReadTxn()\n\n\twatchCh, existing, err := txn.FirstWatch(\"scaling_policy\", \"id\", id)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"scaling_policy lookup failed: %v\", err)\n\t}\n\tws.Add(watchCh)\n\n\tif existing != nil {\n\t\treturn existing.(*structs.ScalingPolicy), nil\n\t}\n\n\treturn nil, nil\n}\n\n// ScalingPolicyByTargetAndType returns a fully-qualified policy against a target and policy type,\n// or nil if it does not exist. This method does not honor the watchset on the policy type, just the target.\nfunc (s *StateStore) ScalingPolicyByTargetAndType(ws memdb.WatchSet, target map[string]string, typ string) (*structs.ScalingPolicy,\n\terror) {\n\ttxn := s.db.ReadTxn()\n\n\tnamespace := target[structs.ScalingTargetNamespace]\n\tjob := target[structs.ScalingTargetJob]","sourceCodeStart":7315,"sourceCodeEnd":7351,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L7315-L7351","documentation":"ScalingPolicyByID fetches a scaling policy by ID with txn.FirstWatch; if the underlying read transaction errors, the failure is wrapped as \"scaling_policy lookup failed: %v\". Note this fires only on memdb read errors — a missing policy simply returns nil, not this error.","triggerScenarios":"GET /v1/scaling/policy/<id> or internal job scaling evaluation when the state store's read transaction fails (bad index lookup, store fault).","commonSituations":"Rare; store-level faults, version-specific memdb issues, or corruption. Not caused by wrong IDs (those return empty results).","solutions":["Inspect the wrapped cause in the error string and agent logs.","Retry the request.","Check Nomad version for known state-store bugs and upgrade if affected."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"policy, err := client.Scaling().GetPolicy(id, nil)\nif err != nil {\n    if strings.Contains(err.Error(), \"scaling_policy lookup failed\") {\n        // store read fault: retry with backoff; a nil/empty result means not found\n    }\n}","preventionTips":["Distinguish not-found (empty result) from read faults (this error) when handling.","Check Nomad release notes for state-store fixes when upgrading."],"tags":["nomad","state-store","scaling-policy","lookup"],"backgroundTag":"state-store-read-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"}