hashicorp/nomad · error

scaling policy lookup failed: %v

Error message

scaling policy lookup failed: %v

What it means

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.

Source

Thrown at nomad/state/state_store.go:7384

		if p.Type == typ {
			existing = p
			break
		}
	}

	if existing != nil {
		return existing, nil
	}

	return nil, nil
}

func (s *StateStore) ScalingPoliciesByIDPrefix(ws memdb.WatchSet, namespace string, prefix string) (memdb.ResultIterator, error) {
	txn := s.db.ReadTxn()

	iter, err := txn.Get("scaling_policy", "id_prefix", prefix)
	if err != nil {
		return nil, fmt.Errorf("scaling policy lookup failed: %v", err)
	}

	ws.Add(iter.WatchCh())

	iter = memdb.NewFilterIterator(iter, scalingPolicyNamespaceFilter(namespace))

	return iter, nil
}

// scalingPolicyNamespaceFilter returns a filter function that filters all
// scaling policies not targeting the given namespace.
func scalingPolicyNamespaceFilter(namespace string) func(any) bool {
	return func(raw any) bool {
		p, ok := raw.(*structs.ScalingPolicy)
		if !ok {
			return true
		}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Inspect the wrapped cause in the error/agent logs.
  2. Retry the query, possibly targeting another server.
  3. Check cluster/store health and Nomad version for known fixes.
Defensive patterns

Strategy: retry

Try / catch

iter, err := /* prefix list call */
if err != nil {
    if strings.Contains(err.Error(), "scaling policy lookup failed") {
        // retry on another server with backoff
    }
}

Prevention

When it happens

Trigger: GET /v1/scaling/policy/prefix/<prefix> (list by ID prefix) when the prefix index query fails.

Common situations: Rare store-level faults; occasionally seen in tooling that does prefix-based pagination against a degraded server.

Related errors


AI-assisted analysis of hashicorp/nomad@482b49bf1a (2026-09-04). Data as JSON: /api/errors/a3aae06d5140f3a4. Report an issue: GitHub.