hashicorp/nomad · error

missing alloc bucket

Error message

missing alloc bucket

What it means

In BoltStateDB.getAllAllocations, a per-allocation bucket under the allocations bucket is nil (corrupt or partially written state store entry); the alloc ID is recorded in the per-alloc error map and iteration continues rather than aborting the restore of all allocations.

Source

Thrown at client/state/db_bolt.go:272

func (s *BoltStateDB) getAllAllocations(tx *boltdd.Tx) ([]*structs.Allocation, map[string]error) {
	allocs := make([]*structs.Allocation, 0, 10)
	errs := map[string]error{}

	allocationsBkt := tx.Bucket(allocationsBucketName)
	if allocationsBkt == nil {
		// No allocs
		return allocs, errs
	}

	// Create a cursor for iteration.
	c := allocationsBkt.BoltBucket().Cursor()

	// Iterate over all the allocation buckets
	for k, _ := c.First(); k != nil; k, _ = c.Next() {
		allocID := string(k)
		allocBkt := allocationsBkt.Bucket(k)
		if allocBkt == nil {
			errs[allocID] = fmt.Errorf("missing alloc bucket")
			continue
		}

		var ae allocEntry
		if err := allocBkt.Get(allocKey, &ae); err != nil {
			errs[allocID] = fmt.Errorf("failed to decode alloc: %v", err)
			continue
		}

		// Handle upgrade path
		ae.Alloc.Canonicalize()
		ae.Alloc.Job.Canonicalize()

		allocs = append(allocs, ae.Alloc)
	}

	return allocs, errs
}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Inspect the Bolt state DB for corruption (boltdd check tooling)
  2. Restore the client state database from a backup or let the client re-adopt allocations
  3. Report per-alloc errors upstream instead of failing the entire listing
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at client/state/db_bolt.go:272 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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