hashicorp/nomad · error

last index mismatch: source=%d, destination=%d

Error message

last index mismatch: source=%d, destination=%d

What it means

Fires in verifyMigration when the source and destination raft logs disagree on LastIndex: the destination WAL is truncated or has extra trailing entries, so the migrated log does not cover the same range.

Source

Thrown at helper/raftutil/migrate.go:277

		return fmt.Errorf("failed to get source last index: %w", err)
	}

	dstFirst, err := dst.FirstIndex()
	if err != nil {
		return fmt.Errorf("failed to get destination first index: %w", err)
	}

	dstLast, err := dst.LastIndex()
	if err != nil {
		return fmt.Errorf("failed to get destination last index: %w", err)
	}

	if srcFirst != dstFirst {
		return fmt.Errorf("first index mismatch: source=%d, destination=%d", srcFirst, dstFirst)
	}

	if srcLast != dstLast {
		return fmt.Errorf("last index mismatch: source=%d, destination=%d", srcLast, dstLast)
	}

	// Verify stable store uint64 keys.
	uint64Keys := []string{"CurrentTerm", "LastVoteTerm"}
	for _, key := range uint64Keys {
		srcVal, err := src.GetUint64([]byte(key))
		if err != nil {
			return fmt.Errorf("failed to get source uint64 key %s: %w", key, err)
		}

		dstVal, err := dst.GetUint64([]byte(key))
		if err != nil {
			return fmt.Errorf("failed to get destination uint64 key %s: %w", key, err)
		}

		if srcVal != dstVal {
			return fmt.Errorf("stable key %s mismatch: source=%d, destination=%d", key, srcVal, dstVal)
		}

View on GitHub (pinned to 482b49bf1a)

Solutions

  1. Re-run the migration after removing the partial WAL directory
  2. Confirm the BoltDB source was not modified concurrently during migration
  3. Fall back to the pre-migration backup if re-migration keeps failing
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at helper/raftutil/migrate.go:277 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/039fb4b0a9b30c8d. Report an issue: GitHub.