{"record":{"id":"a3aae06d5140f3a4","repo":"hashicorp/nomad","slug":"scaling-policy-lookup-failed-v-a3aae0","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":7384,"sourceCode":"\t\tif p.Type == typ {\n\t\t\texisting = p\n\t\t\tbreak\n\t\t}\n\t}\n\n\tif existing != nil {\n\t\treturn existing, nil\n\t}\n\n\treturn nil, nil\n}\n\nfunc (s *StateStore) ScalingPoliciesByIDPrefix(ws memdb.WatchSet, namespace string, prefix string) (memdb.ResultIterator, error) {\n\ttxn := s.db.ReadTxn()\n\n\titer, err := txn.Get(\"scaling_policy\", \"id_prefix\", prefix)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"scaling policy lookup failed: %v\", err)\n\t}\n\n\tws.Add(iter.WatchCh())\n\n\titer = memdb.NewFilterIterator(iter, scalingPolicyNamespaceFilter(namespace))\n\n\treturn iter, nil\n}\n\n// scalingPolicyNamespaceFilter returns a filter function that filters all\n// scaling policies not targeting the given namespace.\nfunc scalingPolicyNamespaceFilter(namespace string) func(any) bool {\n\treturn func(raw any) bool {\n\t\tp, ok := raw.(*structs.ScalingPolicy)\n\t\tif !ok {\n\t\t\treturn true\n\t\t}\n","sourceCodeStart":7366,"sourceCodeEnd":7402,"githubUrl":"https://github.com/hashicorp/nomad/blob/482b49bf1aec006f089bcfc7e632d8f6ac303e5e/nomad/state/state_store.go#L7366-L7402","documentation":"ScalingPoliciesByIDPrefix performs a prefix lookup on the scaling_policy \"id_prefix\" index; a memdb transaction error is wrapped as \"scaling policy lookup failed: %v\". The result is then filtered by namespace, so an empty match set is normal and not an error.","triggerScenarios":"GET /v1/scaling/policy/prefix/<prefix> (list by ID prefix) when the prefix index query fails.","commonSituations":"Rare store-level faults; occasionally seen in tooling that does prefix-based pagination against a degraded server.","solutions":["Inspect the wrapped cause in the error/agent logs.","Retry the query, possibly targeting another server.","Check cluster/store health and Nomad version for known fixes."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"iter, err := /* prefix list call */\nif err != nil {\n    if strings.Contains(err.Error(), \"scaling policy lookup failed\") {\n        // retry on another server with backoff\n    }\n}","preventionTips":["Retry prefix queries transiently; they fail only on store faults, not empty results.","Monitor server health and route queries away from degraded servers."],"tags":["nomad","state-store","scaling-policy","prefix-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"}