nats-io/nats-server · error

Cache lookup for sequence %d in block %d detected no cache:

Error message

Cache lookup for sequence %d in block %d detected no cache: %s

What it means

A cache lookup for a sequence found the block's in-memory cache unusable (nil cache, first-seq 0, empty index, or empty buffer) with the specific reason logged. The store forces cache expiry/rebuild so a later lookup reloads the data from disk instead of serving from stale cache.

Source

Thrown at server/filestore.go:9122

		return nil, errDeletedMsg
	}

	// Detect no cache loaded.
	if mb.cache == nil {
		mb.cache = mb.ecache.Value()
	}
	if mb.cache == nil || mb.cache.fseq == 0 || len(mb.cache.idx) == 0 || len(mb.cache.buf) == 0 {
		var reason string
		if mb.cache == nil {
			reason = "no cache"
		} else if mb.cache.fseq == 0 {
			reason = "fseq is 0"
		} else if len(mb.cache.idx) == 0 {
			reason = "no idx present"
		} else {
			reason = "cache buf empty"
		}
		mb.fs.warn("Cache lookup for sequence %d in block %d detected no cache: %s", seq, mb.index, reason)
		if mb.cache != nil {
			mb.tryForceExpireCacheLocked()
		}
		return nil, errNoCache
	}
	// Check partial cache status.
	if seq < mb.cache.fseq {
		mb.fs.warn("Partial cache: seq %d is less than cache fseq %d", seq, mb.cache.fseq)
		return nil, errPartialCache
	}

	bi, _, hashChecked, err := mb.slotInfo(int(seq - mb.cache.fseq))
	if err != nil {
		return nil, err
	}

	// Update cache activity.
	mb.llts = ats.AccessTime()

View on GitHub (pinned to 3a66a489d2)

Solutions

  1. No data is lost; the cache is rebuilt on demand
  2. If frequent, check memory pressure causing aggressive cache eviction
  3. Ensure the msg block files are readable on disk
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at server/filestore.go:9122 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of nats-io/nats-server@3a66a489d2 (2026-09-02). Data as JSON: /api/errors/0d21ab0f65d73d98. Report an issue: GitHub.